DataCacheX constructor
DataCacheX(
- CacheAdapter _cacheAdapter, {
- CacheAnalytics? analytics,
- int? maxSize,
- int? maxItems,
- EvictionStrategy evictionStrategy = EvictionStrategy.lru,
- int compressionLevel = 6,
Creates a new instance of DataCacheX.
The cacheAdapter
parameter is required to handle the underlying storage.
The analytics
parameter is optional and can be used to track cache performance.
The maxSize
parameter can be used to set a maximum size for the cache in bytes.
The maxItems
parameter can be used to set a maximum number of items in the cache.
The evictionStrategy
parameter can be used to set the eviction strategy to use when the cache is full.
The compressionLevel
parameter can be used to set the compression level (1-9) when compression is enabled.
Implementation
DataCacheX(
this._cacheAdapter, {
CacheAnalytics? analytics,
int? maxSize,
int? maxItems,
EvictionStrategy evictionStrategy = EvictionStrategy.lru,
int compressionLevel = 6,
}) : _analytics = analytics ?? CacheAnalytics(),
_eviction = (maxSize != null || maxItems != null)
? CacheEviction(
_cacheAdapter,
analytics ?? CacheAnalytics(),
maxSize: maxSize,
maxItems: maxItems,
strategy: evictionStrategy,
)
: null,
_compression = Compression(level: compressionLevel);