Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Performance / May 2006

Tip: Looking for answers? Try searching our database.

array caching

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tx_tom - 01 May 2006 13:20 GMT
I am looking for C# code to store and retrieve a 2 dimensional array in the
cache.  I have seen code in this forum for caching arrays but ti does not
work.  I'd be immensely grateful if anyone has an example.
Göran Andersson - 01 May 2006 13:34 GMT
> I am looking for C# code to store and retrieve a 2 dimensional array in the
> cache.  I have seen code in this forum for caching arrays but ti does not
> work.  I'd be immensely grateful if anyone has an example.

Standard question #1:
What do you mean by "not working"?

A two dimensional array is an object, just like a one dimensional array.
It isn't harder to cache a two dimensional array just because it has
more dimensions.
tx_tom - 02 May 2006 02:44 GMT
Hi Goran:

This is the code I tried to use.  It is 2 different technigues to accomplish
the same thing but neither worked.

Thanks in advance

// Get the array from the cache:
MyType[] array = (MyType[]) Cache["key"];

private MyType[] GetArray()
{
// Try to get the return value.
MyType[] retVal = (MyType[]) Cache["key"];

// If the item does not exist, then
// add it here.
if (retVal == null)
{
// Add the array to the cache here.
retVal = <create array here>;

// Add the item to the cache.
Cache["key"] = retVal;
}

// Return the array.
return retVal;
}

>> I am looking for C# code to store and retrieve a 2 dimensional array in the
>> cache.  I have seen code in this forum for caching arrays but ti does not
[quoted text clipped - 6 lines]
>It isn't harder to cache a two dimensional array just because it has
>more dimensions.
Jon Skeet [C# MVP] - 01 May 2006 17:50 GMT
> I am looking for C# code to store and retrieve a 2 dimensional array in the
> cache.  I have seen code in this forum for caching arrays but ti does not
> work.  I'd be immensely grateful if anyone has an example.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

tx_tom - 02 May 2006 02:48 GMT
Sure Jon:

This is the code I tried to use.  It is 2 different technigues to accomplish
the same thing but neither worked.

Thanks in advance

// Get the array from the cache:
MyType[] array = (MyType[]) Cache["key"];

private MyType[] GetArray()
{
// Try to get the return value.
MyType[] retVal = (MyType[]) Cache["key"];

// If the item does not exist, then
// add it here.
if (retVal == null)
{
// Add the array to the cache here.
retVal = <create array here>;

// Add the item to the cache.
Cache["key"] = retVal;
}

// Return the array.
return retVal;
}

This is how I placed the array in the Cache.  I think this works.

Cache["shArray"] = shArray;

>> I am looking for C# code to store and retrieve a 2 dimensional array in the
>> cache.  I have seen code in this forum for caching arrays but ti does not
[quoted text clipped - 5 lines]
>See http://www.pobox.com/~skeet/csharp/complete.html for details of
>what I mean by that.
Göran Andersson - 02 May 2006 15:03 GMT
For a two dimensional array you just declare the array as having two
dimensions:

MyType[,] array = (MyType[,]) Cache["key"];

> Sure Jon:
>
[quoted text clipped - 38 lines]
>> See http://www.pobox.com/~skeet/csharp/complete.html for details of
>> what I mean by that.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.