MemoryAdapter class
A concrete implementation of CacheAdapter that uses an in-memory map for storage.
Example:
// Initialize the memory adapter
final adapter = MemoryAdapter();
// Store a value
await adapter.put('myKey', CacheItem<String>(value: 'myValue', expiry: DateTime.now().add(Duration(days: 1))));
// Retrieve a value
final item = await adapter.get('myKey');
print(item?.value);
- Implemented types
Constructors
- MemoryAdapter.new({bool enableEncryption = false, String? encryptionKey, EncryptionOptions? encryptionOptions})
- Creates a new instance of MemoryAdapter.
Properties
- enableEncryption → bool
-
Indicates if encryption is enabled for this adapter.
final
- encryptionOptions → EncryptionOptions?
-
Returns the encryption options for this adapter.
no setteroverride
- 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< void> -
Clears all data from the cache.
override
-
containsKey(
String key) → Future< bool> -
Checks if the cache contains a value associated with the given
key
.override -
containsKeys(
List< String> keys) → Future<Map< String, bool> > -
Checks if the cache contains values associated with all the given
keys
.override -
delete(
String key) → Future< void> -
Deletes the value associated with the given
key
.override -
deleteAll(
List< String> keys) → Future<void> -
Deletes multiple values associated with the given
keys
.override -
deleteByTag(
String tag) → Future< void> -
Deletes all items in the cache that have the specified tag.
override
-
deleteByTags(
List< String> tags) → Future<void> -
Deletes all items in the cache that have all the specified tags.
override
-
get(
String key) → Future< CacheItem?> -
Retrieves the CacheItem associated with the given
key
.override -
getAll(
List< String> keys) → Future<Map< String, CacheItem> > -
Retrieves multiple CacheItems associated with the given
keys
.override -
getKeys(
{int? limit, int? offset}) → Future< List< String> > -
Returns a list of all keys in the cache.
override
-
getKeysByTag(
String tag, {int? limit, int? offset}) → Future< List< String> > -
Returns a list of all keys in the cache that have the specified tag.
override
-
getKeysByTags(
List< String> tags, {int? limit, int? offset}) → Future<List< String> > -
Returns a list of all keys in the cache that have all the specified tags.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
put(
String key, CacheItem value) → Future< void> -
Stores a
value
in the cache with the givenkey
.override -
putAll(
Map< String, CacheItem> entries) → Future<void> -
Stores multiple values in the cache with the given keys.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited