🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

node-cache-helper

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-cache-helper - npm Package Compare versions

Comparing version
0.0.3
to
0.0.4
+1
-1
index.d.ts

@@ -9,3 +9,3 @@ import * as NodeCache from "node-cache";

constructor(config?: Options);
register(prefix: string, reloadFn: Function);
register(prefix: string, reloadFn: Function, ttl?: number | string);
resetKey(key: string): Promise<any>;

@@ -12,0 +12,0 @@ get(key: string): Promise<any>;

@@ -16,6 +16,7 @@ const NodeCache = require('node-cache')

register(prefix, reloadFn) {
register(prefix, reloadFn, ttl) {
this.registerMap[prefix] = {
prefix,
reloadFn,
ttl,
}

@@ -27,4 +28,3 @@ }

let prefix = spl[0]
let reloadFn = this.registerMap[prefix]?.reloadFn
let { reloadFn, ttl } = this.registerMap[prefix] ?? {}
if (reloadFn == null) {

@@ -35,3 +35,3 @@ return null

let newValue = await reloadFn(...spl)
this.instance.set(key, newValue)
this.instance.set(key, newValue, ttl)
return newValue

@@ -50,3 +50,2 @@ }

this.instance.on('expired', key => {
console.log('expired', key)
this.resetKey(key).then().catch(console.error)

@@ -53,0 +52,0 @@ })

{
"name": "node-cache-helper",
"version": "0.0.3",
"version": "0.0.4",
"description": "",

@@ -5,0 +5,0 @@ "main": "lib/cache.js",