CacheDriver class abstract
An abstract class that defines the interface for cache drivers.
This class serves as a blueprint for implementing various caching mechanisms, such as in-memory caches, file-based caches, or distributed caches like Redis. Implementations must provide concrete methods for storing, retrieving, and managing cached data with time-to-live (TTL) support.
Example usage:
class MyCacheDriver implements CacheDriver {
// Implementation here
}
- Implementers
Constructors
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
-
add(
String key, dynamic value, Duration ttl) → Future< bool> - Stores a value in the cache if the key does not exist.
-
clear(
) → Future< void> - Clears all items from the cache.
-
decrement(
String key, [int amount = 1]) → Future< int> - Decrement the value of an item in the cache.
-
forget(
String key) → Future< void> - Removes a value from the cache by its key.
-
get(
String key) → Future - Retrieves a value from the cache by its key.
-
has(
String key) → Future< bool> - Checks if a key exists in the cache and has not expired.
-
increment(
String key, [int amount = 1]) → Future< int> - Increment the value of an item in the cache.
-
many(
List< String> keys) → Future<Map< String, dynamic> > - Retrieves multiple values from the cache by their keys.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pull(
String key) → Future - Retrieve an item from the cache and delete it.
-
put(
String key, dynamic value, Duration ttl) → Future< void> - Stores a value in the cache with a specified time-to-live (TTL).
-
putMany(
Map< String, dynamic> values, Duration ttl) → Future<void> - Stores multiple values in the cache.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited