2.9.1 • Published 2 years ago
cache-tags v2.9.1
const { TaggableCache: Redis } = require('cache-tags');
// Initialize the Redis client as you would using ioredis.
const redis = new Redis('127.0.0.1:6379');
// Now you can use `redis` as you would with ioredis, or you can enter tagged
// mode.
Promise.resolve()
// Use .tags to enter tagged mode, then call set or get.
.then(() =>
Promise.all([
redis.tags(['first-tag']).set('cache-entry-1', 'Lorem', 1234),
redis.tags(['first-tag', 'boring']).set('cache-entry-2', 'Ipsum', 2324),
])
)
.then(() =>
Promise.all([
// You can scope gets by enterign tagged mode.
redis.tags(['first-tag']).get('cache-entry-1'),
// Or you can get the item as you would do normally.
redis.get('cache-entry-2'),
])
)
.then(console.log) // ['Lorem', 'Ipsum'].
// You can also use tags to list items.
.then(() => redis.tags(['first-tag']).list())
.then(console.log) // ['Lorem', 'Ipsum'].
.then(() => redis.tags(['boring']).list())
.then(console.log) // ['Ipsum'].
// You can also use tags to invalidate items.
.then(() => redis.tags(['first-tag']).list())
.then(() =>
Promise.all([
redis.tags(['first-tag']).get('cache-entry-1'),
redis.get('cache-entry-2'),
])
)
.then(console.log); // []. Cache entries with tag 'first-tag' are gone.
2.9.0
2 years ago
2.9.1
2 years ago
2.8.1
3 years ago
2.8.0
5 years ago
2.7.0
5 years ago
2.6.0
5 years ago
2.5.0
5 years ago
2.4.0
6 years ago
2.3.5
6 years ago
2.3.4
6 years ago
2.3.3
6 years ago
2.3.2
6 years ago
2.3.1
6 years ago
2.3.0
6 years ago
2.2.0
6 years ago
2.1.3
6 years ago
2.1.2
6 years ago
2.1.1
6 years ago
2.1.0
6 years ago
2.0.0
6 years ago
1.2.0
6 years ago
1.1.0
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago