cacher

Creator: coderz1093

Last updated:

0 purchases

cacher Image
cacher Images

Languages

Categories

Add to Cart

Description:

cacher

This is a modification of https://github.com/platelk/dcache, licensed under the MIT License.

Cacher #
Cacher is a simple library to implement application caching in dart inspired by gcache
Features #

Supports expirable Cache, Least Frequently Used, Least recently used, Time aware least recently used.
Supports eviction.
Async loading of expired value.
Automatically load cache if it doesn't exists. (Optional)
Callback for evicted items to perform cleanup (Optional)

Example #
Simple use case #
import 'package:cacher/cacher.dart';

void main() {
Cache c = SimpleCache(storage: SimpleStorage(20));

c.set("key", 42);
print(c.get("key")); // 42
print(c.containsKey("unknown_key")); // false
print(c.get("unknown_key")); // null
}
copied to clipboard
Add logic on eviction. #
import 'package:cacher/cacher.dart';

void main() {
Cache c = SimpleCache<Key, Disposable>(
storage: SimpleStorage(20),
onEvict: (key, value) {
value.dispose();
});
}
copied to clipboard
Loading function #
import 'package:cacher/cacher.dart';

void main() {
Cache c = SimpleCache<int, int>(
storage: SimpleStorage(20),
)..loader = (key, oldValue) => key * 10;

print(c.get(4)); // 40
print(c.get(5)); // 50
print(c.containsKey(6)); // false
}
copied to clipboard
Authors #
Kevin PLATEL

mail : [email protected]
github : https://github.com/platelk
twitter : https://twitter.com/kevinplatel

Harpreet Sangar

mail : [email protected]
github : https://github.com/happy-san

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.