CacheManager class

Manages caching of various game resources.

The binary cache supports optional LRU eviction via maxBinaryEntries. When the limit is reached, the oldest entries (by timestamp) are removed to make room for new ones.

Constructors

CacheManager({int? maxBinaryEntries, bool forceMemoryFallback = false})
Create a cache manager.

Properties

forceMemoryFallback bool
Forces the cache to use only the shared in-memory fast path.
final
hashCode int
The hash code for this object.
no setterinherited
isInitialized bool
Check if cache manager is initialized
no setter
isUsingMemoryFallback bool
Whether the cache is running in headless/test memory-only mode.
no setter
maxBinaryEntries int?
Maximum number of entries in the binary cache before LRU eviction. null means effectively unbounded in in-memory fallback mode.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

captureProfile() MemoryProfileSnapshot
Returns a lightweight profiling snapshot for runtime tuning.
clearAll() Future<void>
Clear all cache entries
dispose() → void
Dispose of the cache manager and close resources
getBinary(String key) Future<Uint8List?>
Retrieve binary data
getBinaryCacheSize() Future<int>
Return the number of entries in the binary cache.
getJson(String key) Future
Retrieve JSON data
getString(String key) Future<String?>
Retrieve a string value
initialize() Future<void>
Initialize the caching system
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove(String key) Future<void>
Clear a specific cache entry (from both storages for simplicity)
setBinary(String key, Uint8List data) Future<void>
Store binary data
setJson(String key, dynamic data) Future<void>
Store JSON data
setString(String key, String value) Future<void>
Store a string value
toString() String
A string representation of this object.
inherited

Operators

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