Add Method
Definition
- Assemblies
- Cuemon.Runtime.Caching.dll
Add(string, object, DateTime, string)
Inserts a cache entry into the cache and adds details about how the entry should be evicted.
public bool Add(string key, object value, DateTime absoluteExpiration, string ns = null)
Parameters
keystringThe unique identifier of the cache.
valueobjectThe stored value of the cache.
absoluteExpirationDateTimeThe absolute expiration date time value from when the cached
valuebecomes invalid and is removed from the cache.nsstringThe optional namespace that provides a scope to the cache.
Returns
- bool
trueif insertion succeeded; otherwise,falsewhen there is already an entry in the cache with the same key.
Exceptions
- ArgumentNullException
keycannot be null.
Add(string, object, IDependency, string)
Inserts a cache entry into the cache and adds details about how the entry should be evicted.
public bool Add(string key, object value, IDependency dependency, string ns = null)
Parameters
keystringThe unique identifier of the cache.
valueobjectThe stored value of the cache.
dependencyIDependencyAn IDependency implementations that monitors changes in the state of the data which a cache entry depends on. If a state change is registered, the cached
valuebecomes invalid and is removed from the cache.nsstringThe optional namespace that provides a scope to the cache.
Returns
- bool
trueif insertion succeeded; otherwise,falsewhen there is already an entry in the cache with the same key.
Exceptions
- ArgumentNullException
keycannot be null.
Add(string, object, IEnumerable<IDependency>, string)
Inserts a cache entry into the cache and adds details about how the entry should be evicted.
public bool Add(string key, object value, IEnumerable<IDependency> dependencies, string ns = null)
Parameters
keystringThe unique identifier of the cache.
valueobjectThe stored value of the cache.
dependenciesIEnumerable<IDependency>A sequence of IDependency implementations that monitors changes in the state of the data which a cache entry depends on. If a state change is registered, the cached
valuebecomes invalid and is removed from the cache.nsstringThe optional namespace that provides a scope to the cache.
Returns
- bool
trueif insertion succeeded; otherwise,falsewhen there is already an entry in the cache with the same key.
Exceptions
- ArgumentNullException
keycannot be null.
Add(string, object, TimeSpan, string)
Inserts a cache entry into the cache and adds details about how the entry should be evicted.
public bool Add(string key, object value, TimeSpan slidingExpiration, string ns = null)
Parameters
keystringThe unique identifier of the cache.
valueobjectThe stored value of the cache.
slidingExpirationTimeSpanThe sliding expiration time from when the cached
valuebecomes invalid and is removed from the cache.nsstringThe optional namespace that provides a scope to the cache.
Returns
- bool
trueif insertion succeeded; otherwise,falsewhen there is already an entry in the cache with the same key.
Exceptions
- ArgumentNullException
keycannot be null.
Add(CacheEntry, CacheInvalidation)
Inserts a cache entry into the cache and adds details about how the entry should be evicted.
public bool Add(CacheEntry entry, CacheInvalidation invalidation)
Parameters
entryCacheEntryThe object representing the cached value for a cache entry.
invalidationCacheInvalidationThe object that contains expiration details for a specific cache entry.
Returns
- bool
trueif insertion succeeded; otherwise,falsewhen there is already an entry in the cache with the same key.
Exceptions
- ArgumentNullException
entrycannot be null -or-invalidationcannot be null.