Skip to content

Simple wrapper around `System.Runtime.Caching`

License

Notifications You must be signed in to change notification settings

rightek/rightek.cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Rightek.Cache

Simple wrapper around System.Runtime.Caching

Basic Usage

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>();

Nuget nuget stats

PM> Install-Package Rightek.Cache

Config API

  • WithTimeToLive: Specify how long value should be stay in cache
  • WithTimeUnit: TimeToLive unit, available values
    • MILLISECOND defalut
    • SECOND
    • MINUTE
    • HOUR
    • DAY
  • WithExpirationType: Expiration policy, available values
  • WithKey: Cache item key, it should be unique per item
  • Configure: You can use this method instead of all above methods and set all configs at once
  • SetDefault: You should call it once at application startup, default setting can be Override using above methods

Core API

  • Set: Add item to cache
  • Get: Get item from cache
  • AddOrGetExisting: Get item from cache or add it to the cache and then return it
  • AddOrGetExistingAsync: Same as AddOrGetExisting but async
  • Remove: Remove item from cache
  • Exists: Check to see item with specific key is exists in cache

License

MIT


Made with ♥ by people @ Rightek

Releases

No releases published

Packages

No packages published

Languages