1.1.3 • Published 1 year ago
lambda_inhouse_cache v1.1.3
LAMBDA_INHOUSE_CACHE
Simple Inhouse Cache for Lambda using dynamodb
lambda_inhouse_cache stores cache in the ephimeral storage of lambda i.e /tmp folder in form of JSON
uses @awsx/dynamodb and aws-sdk
INSTALL
## > With NPM
## npm i lambda_inhouse_cache
USAGE
call getCache
let cache = await getCache(Cached_key,tableName,method,dynamo_query,index)
call setCache
await setCache(key_to_be_cached, data_to_be_cached)
set ttl of cache in your process.env The value is in minutes here 10 stands for 10 minutes ttl
CACHE_TTL: 10
Response
If cache was found
let data = await getCache(Cached_key,tableName,method,dynamo_query,index)
// data.cache stores the cache
/* format of cache
{
cache : {cache is stored here}
}
*/
if(data.cache) return data.cache
else
// data is the response from dynamodb