2.4.1 • Published 5 months ago

@tadashi/find-in-cache v2.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

find-in-cache

NPM version Node.js CI Coverage Status

Find data in cache

Install

$ npm i @tadashi/find-in-cache

Environment variable

variabletyperequireddefaultdescription
REDISstringno127.0.0.1:6379Addresses to connect
REDIS_PWDstringno-Redis password
CACHE_REDIS_PREFIXstringnolibKey prefix
CACHE_REDIS_NAMESPACEstringnofind-in-cacheAvoid conflicts between caches
CACHE_REDIS_DBnumberno0Number of database
CLEAR_CACHE_FIRST_RUNbooleannotrueClear cache when app is started

See more about REDIS and REDIS_PWD in:
https://github.com/lagden/connect-redis

API

find(key: any): any

parametertyperequireddefaultdescription
keyanyyes-data key name

caching(key: any, value: any, ttl: number): boolean

parametertyperequireddefaultdescription
keyanyyes-data key name
valueanyyes-data
ttlnumberno-cache lifetime in seconds

⚠️ if the ttl is not set, the cache will last forever

Usage

import {find, caching, cache} from '@tadashi/find-in-cache'

await find('foo')
// => undefined

await caching('foo', 'bar', 30)
// => true

await find('foo')
// => bar

await cache.clear()
// => cache was cleared

Donate ❤️

BTC: bc1q7famhuj5f25n6qvlm3sssnymk2qpxrfwpyq7g4

License

MIT © Thiago Lagden

2.4.1

5 months ago

2.4.0

5 months ago

2.3.0

11 months ago

2.2.2

1 year ago

2.2.1

2 years ago

2.2.0

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago