3.0.0 • Published 10 months ago

@tadashi/find-in-cache v3.0.0

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

find-in-cache

NPM version Node.js CI Coverage Status

Find in cache

Install

$ npm i @tadashi/find-in-cache

Environment variable

variabletyperequireddefaultdescription
REDISstringno127.0.0.1:6379The address or addresses of the Redis server(s)
REDIS_PWDstringno-The password for authenticating with the Redis server, if required
CACHE_REDIS_PREFIXstringnolibKey prefix
CACHE_REDIS_NAMESPACEstringnofind-in-cacheAvoid conflicts between caches
CACHE_REDIS_DBnumberno0Number of database
CACHE_REDIS_OPTIONSJSONStringno{}See configuration options
CLEAR_CACHE_FIRST_RUNbooleannotrueClear cache when app is started

API

find(key): Promise<*>

parametertyperequireddefaultdescription
keystringyes-The key for which to find the cached value

caching(key, value, ttl): Promise\<Object>

parametertyperequireddefaultdescription
keystringyes-The key under which the value will be stored
valueanyyes-The value to be cached
ttlstring|numberno-The time-to-live for the cache entry, in seconds

!IMPORTANT
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)
// => {'OK', 1}

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

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

!IMPORTANT
Buy me a coffee!
BTC: bc1q7famhuj5f25n6qvlm3sssnymk2qpxrfwpyq7g4

License

MIT © Thiago Lagden

3.0.0

10 months ago

2.4.1

2 years ago

2.4.0

2 years ago

2.3.0

2 years ago

2.2.2

3 years ago

2.2.1

3 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago