Simple wrapper around System.Runtime.Caching
var key = Guid.NewGuid().ToString();
var expected = "value";
// Add value to cache
MemoryCache.Instance.WithKey(key).Set(expected);
// Get value from cache
var actual = MemoryCache.Instance.WithKey(key).Get<string>();PM> Install-Package Rightek.Cache
WithTimeToLive: Specify how long value should be stay in cacheWithTimeUnit:TimeToLiveunit, available values- MILLISECOND defalut
- SECOND
- MINUTE
- HOUR
- DAY
WithExpirationType: Expiration policy, available valuesWithKey: Cache item key, it should be unique per itemConfigure: You can use this method instead of all above methods and set all configs at onceSetDefault: You should call it once at application startup, default setting can be Override using above methods
Set: Add item to cacheGet: Get item from cacheAddOrGetExisting: Get item from cache or add it to the cache and then return itAddOrGetExistingAsync: Same asAddOrGetExistingbutasyncRemove: Remove item from cacheExists: Check to see item with specific key is exists in cache
MIT
Made with ♥ by people @ Rightek