mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-10 18:05:44 +02:00
feat: increase expiry period to 8 years.
Related to #923. Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
bac9180602
commit
a8c1e5cd4a
5 changed files with 12 additions and 6 deletions
|
@ -11,9 +11,9 @@ Indices (say in GETRANGE and SETRANGE commands) should be signed 32 bit integers
|
||||||
SORT does not take any locale into account.
|
SORT does not take any locale into account.
|
||||||
|
|
||||||
## Expiry ranges.
|
## Expiry ranges.
|
||||||
Expirations are limited to 4 years. For commands with millisecond precision like PEXPIRE or PSETEX,
|
Expirations are limited to 8 years. For commands with millisecond precision like PEXPIRE or PSETEX,
|
||||||
expirations greater than 2^27ms are quietly rounded to the nearest second loosing precision of less than 0.001%.
|
expirations greater than 2^28ms are quietly rounded to the nearest second loosing precision of less than 0.001%.
|
||||||
|
|
||||||
## Lua
|
## Lua
|
||||||
We use lua 5.4.4 that has been released in 2022.
|
We use lua 5.4.4 that has been released in 2022.
|
||||||
That means we also support [lua integers](https://github.com/redis/redis/issues/5261).
|
That means we also support [lua integers](https://github.com/redis/redis/issues/5261).
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace dfly {
|
||||||
enum class ListDir : uint8_t { LEFT, RIGHT };
|
enum class ListDir : uint8_t { LEFT, RIGHT };
|
||||||
|
|
||||||
// Dependent on ExpirePeriod representation of the value.
|
// Dependent on ExpirePeriod representation of the value.
|
||||||
constexpr int64_t kMaxExpireDeadlineSec = (1u << 27) - 1;
|
constexpr int64_t kMaxExpireDeadlineSec = (1u << 28) - 1;
|
||||||
|
|
||||||
using DbIndex = uint16_t;
|
using DbIndex = uint16_t;
|
||||||
using ShardId = uint16_t;
|
using ShardId = uint16_t;
|
||||||
|
|
|
@ -30,8 +30,12 @@ class GenericFamilyTest : public BaseFamilyTest {};
|
||||||
|
|
||||||
TEST_F(GenericFamilyTest, Expire) {
|
TEST_F(GenericFamilyTest, Expire) {
|
||||||
Run({"set", "key", "val"});
|
Run({"set", "key", "val"});
|
||||||
auto resp = Run({"expire", "key", "1"});
|
|
||||||
|
|
||||||
|
// sideqik expiry limit
|
||||||
|
auto resp = Run({"expire", "key", absl::StrCat(5 * 365 * 24 * 3600)});
|
||||||
|
EXPECT_THAT(resp, IntArg(1));
|
||||||
|
|
||||||
|
resp = Run({"expire", "key", "1"});
|
||||||
EXPECT_THAT(resp, IntArg(1));
|
EXPECT_THAT(resp, IntArg(1));
|
||||||
AdvanceTime(1000);
|
AdvanceTime(1000);
|
||||||
resp = Run({"get", "key"});
|
resp = Run({"get", "key"});
|
||||||
|
|
|
@ -1040,7 +1040,7 @@ void StringFamily::SetExGeneric(bool seconds, CmdArgList args, ConnectionContext
|
||||||
return (*cntx)->SendError(kInvalidIntErr);
|
return (*cntx)->SendError(kInvalidIntErr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit_vals < 1) {
|
if (unit_vals < 1 || unit_vals >= kMaxExpireDeadlineSec) {
|
||||||
ToLower(&args[0]);
|
ToLower(&args[0]);
|
||||||
return (*cntx)->SendError(InvalidExpireTime(ArgS(args, 0)));
|
return (*cntx)->SendError(InvalidExpireTime(ArgS(args, 0)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -362,6 +362,8 @@ TEST_F(StringFamilyTest, SetEx) {
|
||||||
ASSERT_EQ(Run({"setex", "key", "10", "val"}), "OK");
|
ASSERT_EQ(Run({"setex", "key", "10", "val"}), "OK");
|
||||||
ASSERT_THAT(Run({"ttl", "key"}), IntArg(10));
|
ASSERT_THAT(Run({"ttl", "key"}), IntArg(10));
|
||||||
ASSERT_THAT(Run({"setex", "key", "0", "val"}), ErrArg("invalid expire time"));
|
ASSERT_THAT(Run({"setex", "key", "0", "val"}), ErrArg("invalid expire time"));
|
||||||
|
ASSERT_EQ(Run({"setex", "key", StrCat(5 * 365 * 24 * 3600), "val"}), "OK");
|
||||||
|
ASSERT_THAT(Run({"setex", "key", StrCat(1 << 30), "val"}), ErrArg("invalid expire time"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(StringFamilyTest, Range) {
|
TEST_F(StringFamilyTest, Range) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue