chrome_storage_cache 0.1.2 copy "chrome_storage_cache: ^0.1.2" to clipboard
chrome_storage_cache: ^0.1.2 copied to clipboard

outdatedDart 1 only

A Chrome Storage backed implementation of quiver's Cache.

chrome_storage_cache #

A quiver:Cache implementation backed by chrome.storage.local.

Usage #

Cache<K,V> myCache = new StorageCache('my-prefix');

myCache.set('favoriteColor','green');

myCache.get('favoriteColor').then((item) => print(item));
#=> 'green'

myCache.get('spoon', ifAbsent: (key) => 'There is no $key.');
#=> 'There is no spoon.'

myCache.get('spoon').then((item) => print(item));
#=> 'There is no spoon.'

Caveats #

  • This is a work in progress. Proceed with caution.
  • This has only been tested on Chrome Apps, not Chrome Extensions.
  • You must supply a prefix to the StorageCache constructor.
  • This only works for objects that can be serailzed via the Chrome Storage API. See below for more information.

Object serialization #

From the Chrome App JavaScript API docs:

Primitive values such as numbers will serialize as expected. Values with a typeof "object" and "function" will typically serialize to {}, with the exception of Array (serializes as expected), Date, and Regex (serialize using their String representation).

The behavior under Dart is identical.

Further reading #

0
likes
20
points
14
downloads

Publisher

unverified uploader

Weekly Downloads

A Chrome Storage backed implementation of quiver's Cache.

Homepage

License

unknown (license)

Dependencies

chrome, quiver

More

Packages that depend on chrome_storage_cache