fmap 0.4.0 fmap: ^0.4.0 copied to clipboard
Simple approach to caching or persistent blob storage. A Map-like object for accessing data stored on the filesystem.
import 'dart:typed_data';
import 'package:fmap/fmap.dart';
import 'package:path/path.dart' as pathlib;
import 'dart:io';
void main() {
// let's place the cache in the temp directory
String dirPath = pathlib.join(Directory.systemTemp.path, "myCache");
// creating the cache
final fmap = Fmap(Directory(dirPath));
// reading bytes from cache
Uint8List? myData = fmap["myKey"];
print(myData); // on first start it's null
// saving two bytes
fmap["myKey"] = [0x23, 0x21];
// after restart diskCache["myKey"] will load the data
}