IwsMemoryCache class

In-memory cache implementation with TTL support and various eviction policies.

This implementation provides fast access to cached data stored in memory with automatic expiration, size limits, and configurable eviction strategies.

Implemented types

Constructors

IwsMemoryCache({int? maxSize, EvictionPolicy evictionPolicy = EvictionPolicy.lru, Duration cleanupInterval = const Duration(minutes: 5)})
Creates a new in-memory cache instance.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clear() Future<bool>
Removes all values from the cache.
override
close() Future<void>
Closes the cache and releases resources. For persistent cache, ensures all data is written to disk.
override
containsKey(String key) Future<bool>
Checks if a valid (non-expired) value exists for the given identifier.
override
evictExpired() Future<int>
Automatically removes all expired elements.
override
get<T>(String key) Future<T?>
Retrieves a value from the cache by its identifier.
override
getItemInfo(String key) Future<CacheItemInfo?>
Gets information about the state of an element in cache.
override
getStats() Future<CacheStats>
Gets cache usage statistics.
override
isEmpty() Future<bool>
Checks if the cache is empty.
override
keys() Future<List<String>>
Gets all keys stored in the cache.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
put(String key, dynamic value, {Duration? ttl}) Future<bool>
Stores a value in the cache with a unique identifier.
override
remove(String key) Future<bool>
Removes a specific value from the cache.
override
removeAll(List<String> keys) Future<int>
Removes multiple values from the cache.
override
setMaxSize(int? maxSize, {EvictionPolicy? evictionPolicy}) Future<void>
Sets the maximum cache size (applies mainly to in-memory cache).
override
size() Future<int>
Gets the total number of elements in the cache.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited