
Security News
Python Tools Are Quickly Adopting the New pylock.toml Standard
pip, PDM, pip-audit, and the packaging library are already adding support for Python’s new lock file format.
@cacher/cacher
Advanced tools
Modern implementation of key-value storage
Node.js 14.0.0 or newer is required
yarn add @cacher/cacher
npm i @cacher/cacher
import { Cacher } from '@cacher/cacher';
interface IMyData {
someData: boolean;
}
const cacher = new Cacher<IMyData>({
namespace: 'users'
});
async function run() {
// Single
const { 1: user } = await cacher.get({
key: '1',
// alias: 'user'
});
// With alias
const { user } = await cacher.get({
key: '1',
alias: 'user'
});
// Multi get
const result = await cacher.get([
{ key: '1' },
{ key: '2' },
{ key: '3' },
{ key: '4' }
]);
// result[id] // => IMyData | undefined
// Set
await cacher.set({
key: '1',
value: {
someData: true
},
// ms
// ttl: 10_000
});
// Multi set
await cacher.set([
{
key: '1',
value: {
someData: true
},
// ms
// ttl: 10_000
},
{
key: '2',
value: {
someData: true
},
// ms
// ttl: 10_000
}
]);
// Increment
// /!\ Cacher data must be float
await cacher.increment({
key: '1',
value: 5
});
// Multi set
await cacher.increment([
{
key: '1',
value: 2
},
{
key: '2',
value: 4
}
]);
// Delete
await cacher.delete('1');
// Multi delete
await cacher.delete(['1', '2', '3']);
// Update ttl
await cacher.touch({
key: '1',
ttl: 60_000
});
// Multi update ttl
await cacher.touch([
{
key: '1',
ttl: 60_000
},
{
key: '2',
ttl: 60_000
}
]);
// Clear all namespace
await cacher.clear();
}
run().catch(console.log);
import { Cacher } from '@cacher/cacher';
import { RedisAdapter } from '@cacher/redis';
const adapter = new RedisAdapter();
const cacher = new Cacher({
adapter,
namespace: 'users'
});
FAQs
Modern implementation of key-value storage
We found that @cacher/cacher demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pip, PDM, pip-audit, and the packaging library are already adding support for Python’s new lock file format.
Product
Socket's Go support is now generally available, bringing automatic scanning and deep code analysis to all users with Go projects.
Security News
vlt adds real-time security selectors powered by Socket, enabling developers to query and analyze package risks directly in their dependency graph.