473,405 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

CollectionBase in the Cache

Hi

I am trying to Cache an Object that inherits from CollectionBase.

My logic here, is when the Object is instantiated, try retrieve its data out
the Cache, if its null, retrieve the data from its source (Xml file).

Now i'm not sure what to Cache, or what to retrieve.

I've tried
this.InnerList = HttpContext.Current.Cache["MyCacheName"];

But as this InnerList is read-only, i cannot so this.

So:
What should i Cache/Retrieve to get this working

TIA
Nov 19 '05 #1
2 1214
Why not cache the object itself "this"?

public static MyObject GetInstance()
{
MyObject instance = (MyObject)Cache["MyCacheName"];
if (instance == null)
{
instance = GetFromYourXMlFile();
Cache.Insert("MyCacheName", instance,whatever, whatever,whatever);
}
return instance;
}
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Grant Merwitz" <gr***@workshare.com> wrote in message
news:OR*************@TK2MSFTNGP15.phx.gbl...
Hi

I am trying to Cache an Object that inherits from CollectionBase.

My logic here, is when the Object is instantiated, try retrieve its data
out the Cache, if its null, retrieve the data from its source (Xml file).

Now i'm not sure what to Cache, or what to retrieve.

I've tried
this.InnerList = HttpContext.Current.Cache["MyCacheName"];

But as this InnerList is read-only, i cannot so this.

So:
What should i Cache/Retrieve to get this working

TIA

Nov 19 '05 #2
Thanks, Thats not a bad idea

What i did end up doing, is using the AddRange method to push it into an
ArrayList,
then Cached that
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:eC**************@TK2MSFTNGP14.phx.gbl...
Why not cache the object itself "this"?

public static MyObject GetInstance()
{
MyObject instance = (MyObject)Cache["MyCacheName"];
if (instance == null)
{
instance = GetFromYourXMlFile();
Cache.Insert("MyCacheName", instance,whatever, whatever,whatever);
}
return instance;
}
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Grant Merwitz" <gr***@workshare.com> wrote in message
news:OR*************@TK2MSFTNGP15.phx.gbl...
Hi

I am trying to Cache an Object that inherits from CollectionBase.

My logic here, is when the Object is instantiated, try retrieve its data
out the Cache, if its null, retrieve the data from its source (Xml file).

Now i'm not sure what to Cache, or what to retrieve.

I've tried
this.InnerList = HttpContext.Current.Cache["MyCacheName"];

But as this InnerList is read-only, i cannot so this.

So:
What should i Cache/Retrieve to get this working

TIA


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Steve M | last post by:
I have subclassed CollectionBase. I have also implemented GetEnumerator(). I have tried to set the DataSource of a DataGrid to an instance of my subclass. However, the items in the grid are not...
7
by: m. pollack | last post by:
Hi all, I've been using the CollectionBase class to implement a strongly-typed collection, but I have noticed that the RemoveAt method does not seem to call the "On" hook methods (OnRemove,...
2
by: m.pollack | last post by:
Hi all, I have an application which uses a class object that contains a collection. In order to use the PropertyGrid control to expose properties to the user at runtime, I created a...
1
by: alanrn | last post by:
I've implemented a number of strongly-typed collections that inherit from CollectionBase and recently noticed something that I don't fully understand. CollectionBase defines method RemoveAt(). ...
0
by: Mike Pollett | last post by:
Hi, I have used the ISerializable interface before and the code below worked fine. Until I derived it from CollectionBase. The code will still serialize and deserialize the properties in this class...
5
by: Eric Johannsen | last post by:
I have a simple object that inherits from CollectionBase and overrides the Count property: namespace MyTest { public class CollTest : System.Collections.CollectionBase { public override int...
2
by: Samuel R. Neff | last post by:
What's the advantage of inheriting from CollectionBase as opposed to just implementing IList? It seems that it saves you from having to implement a few properties (Clear, CopyTo, Count,...
0
by: LIJO CHEERAN | last post by:
Hello friends I am trying to study about CollectionBase. I have inherited CollectionBase in the class TheCollection.cs. I am using the “TheCollection. in an aspx page to store objects...
3
by: Tony Johansson | last post by:
Hello! Sorry for opening up this task again. I want to fully understand this List that is return from CollectionBase. According to you is List in CollectionBase implemented something like...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.