Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
cache-manager-sqlite
Advanced tools
Readme
A modern SQlite cache store for node-cache-manager. Featuring:
async
/await
support with Promisemset
/mget
supportjson
or cbor
default: cbor
)The goal was to have a local key value storage built on top of proven technology. While other options like node-cache-manager-fs-binary have similar functionality; they are littered with all sort of problems from race conditions, (multi-process) to corruption. SQLite on the other end has been battle tested, and using WAL allows multiple node processes (forked web servers) to share the same cache across various processes, without the headaches of flat file based systems.
SQLite based storage is ideal for:
npm i cache-manager-sqlite
const sqliteStore = require('cache-manager-sqlite')
const cacheManager = require('cache-manager')
// SQLite :memory: cache store
const memStoreCache = cacheManager.caching({
store: sqliteStore,
options: {
serializer: 'cbor', // default is 'json'
ttl: 20 // TTL in seconds
}
})
// On disk cache on employees table
const cache = cacheManager.caching({
store: sqliteStore,
name: 'employees',
path: '/tmp/cache.db',
options: {
serializer: 'cbor'
}
})
// TTL in seconds
await cache.set('foo', {test: 'bar'}, {ttl: 10})
const value = await cache.get('foo')
const cacheManager = require('cache-manager')
const redisStore = require('cache-manager-ioredis')
const sqliteStore = require('cache-manager-sqlite')
const redisCache = cacheManager.caching({ store: redisStore, db: 0, ttl: 600 })
const sqliteCache = cacheManager.caching({ store: sqliteStore, path: '/tmp/cache.db', name: 'users', options: { ttl: 600 } })
const multiCache = cacheManager.multiCaching([sqliteCache, redisCache])
// Basic get/set
await multiCache.set('foo2', 'bar2', { ttl: customTTL })
const v = await multiCache.get('foo2')
// Wrap call example
const userId = 'user-1'
// Optionally pass ttl
await multiCache.wrap(userId, { ttl: customTTL }, async () => {
console.log("Calling expensive service")
await getUserFromExpensiveService(userId)
})
// set and get multiple
await multiCache.mset('foo1', 'bar1', 'foo0', 'bar0') //Uses default TTL
await multiCache.mset('foo1', 'bar1', 'foo3', 'bar3', {ttl: customTTL})
await multiCache.mget('foo1', 'foo3')
The node-cache-manager-sqlite
is licensed under the MIT license.
FAQs
A modern SQLite store for node-cache-manager
The npm package cache-manager-sqlite receives a total of 295 weekly downloads. As such, cache-manager-sqlite popularity was classified as not popular.
We found that cache-manager-sqlite 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.