Skip to content
James Craig edited this page May 15, 2014 · 1 revision

CUL attempts to simplify catching a bit and offers its own solution when you don't know what type of application your code may run in. For instance if you're writing code that may be in an MVC app or a desktop app, you may want a thread safe cache in both instances without changing your code. CUL lets you do that using the built in cache:

10.Cache("A");

The Cache extension method can be found in the Utilities.DataTypes namespace. It attaches to all objects and lets you cache directly to the built in cache for CUL. Getting the data back out is rather simple also:

int Result="A".GetFromCache<int>();

This would get the value 10 from the cache and return it as the result. In situations where you know that you will be running in a web app, it also lets you tie directly into the various ASP.Net caches (Cache, Session, Item) by specifing the cache type:

10.Cache("A","Session");

The above code would save 10 to the session. Similarly you can get it out again by specifying the cache type:

int Result="A".GetFromCache<int>("Session");

You can also create your own cache types by implementing the CacheBase class in Utilities.DataTypes.Caching.BaseClasses. The system will automatically detect them and hook them up for you so that you can start using them.

Clone this wiki locally