Mindscape LightSpeed - User Reference & API Documentation
Caching

LightSpeed supports the concept of a “second-level” cache. A second-level cache is an application-wide cache designed to reduce the number of database hits made by an application. LightSpeed supports a pluggable cache provider model and provides implementations for two cache providers out of the box:

Enabling Caching

Caching may be enabled programmatically or through a configuration file.

CopyEnabling Caching Programmatically
1LightSpeedContext.Cache = new CacheBroker(new DefaultCache());

Using Caching

Caching may be applied declaratively at the model level by applying the CachedAttribute.

CopyApplying the CachedAttribute
1[Cached(ExpiryMinutes=15)]
2public class Classification : Entity<int>
3{
4  // ...

When LightSpeed loads an entity decorated with the CachedAttribute it will immediately add it to the second-level cache. Any subsequent request for that entity by it’s id will cause a cache hit and the database load will be avoided.