-
Notifications
You must be signed in to change notification settings - Fork 0
Caching
You can add an object of any type to cache along with a unique key. A key can be any arbitary string as long as its unique in the cache for a given object. Once you add an object to cache, you can retrieve it anytime after that.
In DevAccelerate Core, you create an instance of the IDaCacheManager type by calling the CreateCacheManager method of the DaApplicationContext class. Once you have a cache manager object, you can call its members to work with the underlying caching framework.
Before you can do any caching operations such as adding and retrieving objects from cache, you need to create a cache manager:
var cacheManager = DaCacheManagerFactory.CreateCacheManager();
You call the Add method to add an object to the cache:
var employee = new Employee();
cacheManager.Add("employee_" + employee.Id, employee);
You can call the GetData method to retrieve an object from cache:
var employee = cacheManager.GetData("employee_" + employeeId));
You can call the Contains method to check if a key exists in cache:
if(cacheManager.Contains("employee_" + employeeId))
{
// Do something
}
You can call the Flush method to clear cache:
cacheManager.Flush();