CacheFileManager class
Manages cache file paths and file operations. Includes LRU (Least Recently Used) cache eviction to prevent unbounded growth.
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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- maxCacheSizeBytes ↔ int
-
Maximum cache size in bytes (default: 500MB)
getter/setter pair
Static Methods
-
clearAll(
) → Future< void> - Delete all cached files.
-
delete(
String url) → Future< void> - Delete cached file for URL.
-
ensureFile(
String url) → Future< String> - Create empty file if it doesn't exist.
-
evictIfNeeded(
) → Future< void> - Evict oldest files if cache exceeds maximum size. Uses LRU (Least Recently Used) strategy based on file access time. Evicts until cache is under 80% of max size.
-
evictIfNeededThrottled(
) → Future< void> - Throttled eviction to avoid scanning too often.
-
exists(
String url) → Future< bool> - Check if file exists for URL.
-
getCacheDir(
) → Future< String> - Get the cache directory, creating if needed.
-
getFilePath(
String url) → Future< String> - Get file path for a URL. Does not create the file.
-
getFileSize(
String url) → Future< int> - Get current file size. Returns 0 if file doesn't exist.
-
getTotalCacheSize(
) → Future< int> - Get total cache size in bytes.
-
getUrlHash(
String url) → String - Get MD5 hash of URL. Public for use by HLS cache.
-
updateAccessTime(
String url) → Future< void> - Update access time for a file (marks it as recently used). Call this when a video is played to keep it in cache longer.