Skip to content

v6.0.0

Latest
Compare
Choose a tag to compare
@fregante fregante released this 24 Jul 21:47
· 1 commit to main since this release

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

v5.1.1...v6.0.0