webext-storage-cache

Cache values in your Web Extension and clear them on expiration. Also includes a memoize-like API to cache any function results automatically

MIT License

Downloads
3.1K
Stars
79
Committers
4

Bot releases are hidden (Show)

webext-storage-cache - Latest Release

Published by fregante about 1 year ago

Major

  • Add CachedValue and CachedFunction (#41) 5255795

The API has changed to improve type safety and extend the capabilities of cache.function.

Migration guide

You can use the legacy API for a gradual migration, but you should start using the new functions before the next major version.

// v5
await cache.set('user-id', 510, {days: 2});
const id = await cache.get('user-id');

// v6
const idCache = new CachedValue('user-id', {maxAge: {days: 2}});

await idCache.set(510);
const id = await idCache.get();
// v5
const cachedGetHTML = cache.function(getHTML, {
	cacheKey: args => args.join(','),
	maxAge: {days: 2},
});

const html = await cachedGetHTML('info.html');

// v6
const cache = new CachedFunction('html', {
	maxAge: {days: 2},
);

const html = await cache.get('info.html');

Bugfixes

  • Only use the storage as cache, not memory (#37) a54fc58

https://github.com/fregante/webext-storage-cache/compare/v5.1.1...v6.0.0

webext-storage-cache -

Published by fregante over 1 year ago

webext-storage-cache -

Published by fregante about 2 years ago

  • Add method to force a refresh from a cached function (#33) 126304e

https://github.com/fregante/webext-storage-cache/compare/v5.0.1...v5.1.0

webext-storage-cache -

Published by fregante about 2 years ago

  • Update dependencies (#32) 3b6f61e
  • Allow import in Node/test environments without causing errors

https://github.com/fregante/webext-storage-cache/compare/v5.0.0...v5.0.1

webext-storage-cache -

Published by fregante almost 3 years ago

Changes

It should not bring any breaking changes, but I released it as a major version for safety. The minimum browser version probably increased slightly due to the "es2020" TypeScript output.

  • Update dependencies and lint repo 05102c5
  • Allow cache.set(x, undefined) to delete the cached item (#26) c7a1e23

https://github.com/fregante/webext-storage-cache/compare/v4.2.0...v5.0.0

webext-storage-cache -

Published by fregante almost 4 years ago

  • Memoize cache.function so it doesn't get called multiple times (#28) 59790ad

https://github.com/fregante/webext-storage-cache/compare/v4.1.1...v4.2.0

webext-storage-cache -

Published by fregante about 4 years ago

  • Don't purge the cache on just any alarm (#24) 1354876

https://github.com/fregante/webext-storage-cache/compare/v4.1.0...v4.1.1

webext-storage-cache -

Published by fregante about 4 years ago

Enhancements

  • Use chrome.alarms to purge cache where available (#23) a2c38a0

It's not required, but to use this you'll have to include alarms as a permission. This does not appear to the user.

Bugfixes

  • Verify cache expiration in has() and function() (#22) d61d250

https://github.com/fregante/webext-storage-cache/compare/v4.0.0...v4.1.0

webext-storage-cache -

Published by fregante about 4 years ago

Major Changes

  • Use objects to define readable expiration values (#20) 46ca320
webext-storage-cache -

Published by fregante over 4 years ago

Major Changes

  • Loan HTTP Cache terminology (expiration became maxAge): e6411c9f545559f621d78cdc0724b95b9d8916b4

Minor Changes

  • Add stale-while-revalidate behavior: #15
webext-storage-cache -

Published by fregante over 4 years ago

Patches

  • Improve ESM support: 3edfc37d6b6e2a00ec7c87c1ef397d2194872e17
  • Speed and readability improvements: f508752d24b8549a1d32aad43ddd2a02618d563e
  • Add tests: 47b0077fe94b4ee765582bb03276ccd3269dc3e9
webext-storage-cache -

Published by fregante over 4 years ago

Minor Changes

  • Accept undefined in .set and .function (skips the cache): #14
webext-storage-cache -

Published by fregante almost 5 years ago

Patches

  • Fix declaration order: 370647d887c878ca907de0623692be1766a72458
webext-storage-cache -

Published by fregante almost 5 years ago

Minor Changes

  • Add cache.clear() method: 2936f2d405f84fe3e7b875d837705e3b1c156870
  • Add undocumented webextStorageCache global: 9f64562426ada0fd5bfc832c8bb044d9d178e80e

Patches

  • Improve autocomplete when importing this module: ff8d55bbaa22628985954a8b1dec3ba188f4f990
webext-storage-cache -

Published by fregante almost 5 years ago

Patches

  • Revert "Improve cacheable value type": 888bcd230f86d43757baa36b012f978836b3fbf7
webext-storage-cache -

Published by fregante almost 5 years ago

Minor Changes

  • Add isExpired option to cache.function: #10

Patches

  • Improve cacheable value type: 953eb83b3ddc1e965beddf13f2b8a6fed88e0b3a
webext-storage-cache -

Published by fregante almost 5 years ago

Major Changes

Minor Changes

  • Add cache.function method: #5

Patches

  • Add expected types testing via tsd: 44f82499a73fc2ba045e20b348faf860dcc615c7
webext-storage-cache -

Published by fregante over 5 years ago

Patches

  • Add ES Module: b10b25ffa86bc3dea3c418e58c79a6bbc5ef0605
webext-storage-cache -

Published by fregante over 5 years ago

Major Changes

  • Convert to TypeScript; Drop polyfill requirement: 90d4bab25f78b67822f2568c1cb55f634f668649

Minor Changes

  • Add delete method: 65c89d2ddb3f07038e1efc2cf8df589c41d46686
webext-storage-cache -

Published by fregante over 5 years ago

Initial release