Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use one instance of NodeCache per DB collection... #306

Open
LucasBrazi06 opened this issue May 3, 2023 · 2 comments
Open

Use one instance of NodeCache per DB collection... #306

LucasBrazi06 opened this issue May 3, 2023 · 2 comments

Comments

@LucasBrazi06
Copy link

LucasBrazi06 commented May 3, 2023

I would like to use the TTL at NodeCache's instance level and not per record.

Then I'll be notified only once when the instance data is expired and I will reload ALL the cache at once.

When instance is created, the TTL provided is applied to the instance

    const nodeCache = new NodeCache( {
      instanceTTL: 600,   // Instance TTL
      checkperiod: 100,
    });

This notification should be called only once after instance expiration and I will put the code here to reload the whole cache:

    nodeCache.on( "instance_expired", (instance: NodeCache) => {
        // Reload the whole cache here from the DB
    });

Is it possible?

@deepam-kapur
Copy link

Can I work on this?

@AggelosAst
Copy link

AggelosAst commented Aug 28, 2023

From what i understood, this is what youre asking for:

const nodeCache1 = new NodeCache( {
     stdTTL: 600,   // TTL for nodeCache1 
     checkperiod: 100,
});

const nodeCache2 = new NodeCache( {
     stdTTL: 400,   // TTL for nodeCache2
     checkperiod: 100,
});

// . . .

nodeCache2.on( "key_expired", (key, value) => {
       //  . . .
});

nodeCache1.on( "key_expired", (key, value) => {
       //  . . .
});

And, yes thats possible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants