Open QuChen88 opened 1 year ago
Submitted PR to address this https://github.com/RedisLabsModules/redismodule-rs/pull/276
@gkorland @MeirShpilraien Another option instead of adding a remove_expire
method (in PR #276) is to change the signature of set_expire
to receive a c_longlong
instead of Duration
, so the value REDISMODULE_NO_EXPIRE
could be passed as well, which will allow to remove expiration.
Currently Duration
is unsigned, and when receiving values beyond i64
, i64::try_from
will fail.
Changing to c_longlong
would fail in build time instead of run time with values beyond i64
.
However since changing the API (to be stricter) is a breaking change it can only be done in a major version, so we should also add a new remove_expire
method.
Agree?
BTW, this would not entirely prevent failures even with c_longlong
value, but would narrow down the current range of erroneous values (i64::try_from
would still be able to fail since value is multiplied by 1000 when converting to nanoseconds)
I noticed that when I open a key for writing via
context.open_key_writable()
, I can only callset_expire()
with a duration that is >= 0. However, I noticed the low level APIraw::set_expire()
takes the expiration timestamp asc_long_long
which can beREDISMODULE_NO_EXPIRE
to make the key not expire. In this case there doesn't seem to be a way for me to do this using theset_expire()
API. See https://github.com/RedisLabsModules/redismodule-rs/blob/cc0532783ab9ff2302ef819d7c7c8977ff69e801/src/key.rs#L269i.e.
Is there a way for me to remove the expiration of the key using the
RedisKeyWritable
APIs? I tried to call theraw::set_expire()
method but it seems like it needsRedisModuleKey
as parameter. But theRedisModuleKey
field insideRedisKeyWritable
is private and can't be accessed. See https://github.com/RedisLabsModules/redismodule-rs/blob/cc0532783ab9ff2302ef819d7c7c8977ff69e801/src/key.rs#L169