-
Notifications
You must be signed in to change notification settings - Fork 350
Added support for setting TTL on a Table managed entry. #526
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
Changes from 10 commits
3bd9672
55a14f4
93bafee
9292af7
9d2f6bb
1ef8da5
1322886
9dca57e
0ffe760
e6ac594
46cf41e
dd19972
7304f02
b52dc16
da3a88c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,7 +123,7 @@ void Table::hset(const string &key, const std::string &field, const std::string | |
| } | ||
|
|
||
| void Table::set(const string &key, const vector<FieldValueTuple> &values, | ||
| const string& /*op*/, const string& /*prefix*/) | ||
| const string& /*op*/, const string& /*prefix*/, const int64_t &ttl) | ||
| { | ||
| if (values.size() == 0) | ||
| return; | ||
|
|
@@ -136,6 +136,19 @@ void Table::set(const string &key, const vector<FieldValueTuple> &values, | |
| { | ||
| m_pipe->flush(); | ||
| } | ||
|
|
||
| if (ttl != DEFAULT_DB_TTL) | ||
| { | ||
| // Configure the expire time for the entry that was just added | ||
| cmd.formatEXPIRE(getKeyName(key), ttl); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Please indent with 4x spaces #Closed
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated indents in last commit |
||
|
|
||
| m_pipe->push(cmd, REDIS_REPLY_INTEGER); | ||
|
|
||
| if (!m_buffered) | ||
| { | ||
| m_pipe->flush(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does RedisPipeline support enqueuing of more than one command without it being flushed inbetween?
If it does the code can be changed to:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By design, yes. In your proposed code, you can further improve by move |
||
| } | ||
| } | ||
| } | ||
|
|
||
| void Table::del(const string &key, const string& /* op */, const string& /*prefix*/) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hiredis internally implement some int length. ref: https://github.com/redis/hiredis/blob/2d9d77518d012a54ae34f9822e4b4d19823c4b75/hiredis.c#L434
Seems like
%lldis for int64_t. Could you check and add unit test? #ClosedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I will update it to %lld and add/extend an UT to also issue a set with configured TTL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return in void function? formta() also is void?