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

Time-To-Live like Redis Expire #64

Closed
heri16 opened this issue Jul 7, 2018 · 2 comments
Closed

Time-To-Live like Redis Expire #64

heri16 opened this issue Jul 7, 2018 · 2 comments

Comments

@heri16
Copy link
Contributor

@heri16 heri16 commented Jul 7, 2018

Feature request for TTL like Redis expire & persist command.

@only-cliches
Copy link
Owner

@only-cliches only-cliches commented Jul 20, 2018

This feature is live in 1.7.1

There's now an optional .ttl() function for each query.

// delete the inserted record after 20 seconds
nSQL("users").query("upsert", {...}).ttl(20).exec()... 

// remove specific columns from the updated/inserted records after 20 seconds
nSQL("users").query("upsert", {...}).ttl(20, ["col1", "col2"]).exec()... 

You can also query the TTL status of a given row:

nSQL("users").expires(2 /* Primary key */).then((status) => {
    /**
     * {
     *   time: 10, // seconds until timeout, -1 if no timeout
     *   cols: [] // columns being cleared
     * }
     */
    console.log(status);
});

or remove the TTL:

nSQL("users").clearTTL(2 /* Primary key */).then...

Hope this helps!

@thuykaka
Copy link

@thuykaka thuykaka commented Sep 18, 2020

Is TTL support now? When I check status, it always return -1.

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

Successfully merging a pull request may close this issue.

None yet
3 participants