DVDatabaseCacheAdapter class

Cache backed by a DVDatabaseAdapter, so cache entries survive process restarts and can share the application's database.

With SqliteDVDatabaseAdapter this is the zero-config persistent cache the spec calls for; the same adapter works over any future SQL adapter.

The column is cache_key rather than key because KEY is reserved in MySQL, and quoting it differs per dialect.

Values are stored as JSON, so only JSON-encodable values can be cached. A value that cannot be encoded raises ArgumentError on write rather than being silently dropped. Note the round trip is JSON's, not Dart's: a List<String> returns as List<dynamic>, so read it back as List<Object?> and convert.

Implemented types

Constructors

DVDatabaseCacheAdapter(DVDatabaseAdapter database, {String tableName = 'dartvel_cache'})

Properties

database → DVDatabaseAdapter
final
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tableName → String
final

Methods

clear() → Future<void>
override
delete(String key) → Future<void>
Removes key. Named as DV.Cache.delete is, so the adapter and the call an application makes say the same thing.
override
initialize() → Future<void>
Creates the backing table when it does not exist. Called automatically on first use; call it eagerly at boot to surface schema errors early.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
purgeExpired() → Future<int>
Removes expired entries. Reads already ignore them; this reclaims space.
override
read(String key) → Future<Object?>
override
toString() → String
A string representation of this object.
inherited
write(String key, Object? value, Duration? ttl) → Future<void>
override

Operators

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