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 · 1 comment

Comments

Projects
None yet
2 participants
@heri16
Copy link
Contributor

commented Jul 7, 2018

Feature request for TTL like Redis expire & persist command.

@ClickSimply

This comment has been minimized.

Copy link
Owner

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.