Skip to content

Commit

Permalink
Add new method to remove expiration for RedisKeyWritable.
Browse files Browse the repository at this point in the history
  • Loading branch information
QuChen88 committed Feb 4, 2023
1 parent 282e35d commit a85ce49
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use raw::KeyType;
use crate::native_types::RedisType;
use crate::raw;
use crate::redismodule::REDIS_OK;
use crate::redisraw::bindings::REDISMODULE_NO_EXPIRE;
use crate::stream::StreamIterator;
use crate::RedisError;
use crate::RedisResult;
Expand Down Expand Up @@ -285,6 +286,16 @@ impl RedisKeyWritable {
}
}

pub fn remove_expire(&self) -> RedisResult {
match raw::set_expire(self.key_inner, REDISMODULE_NO_EXPIRE.into()) {
raw::Status::Ok => REDIS_OK,

// Error may occur if the key wasn't open for writing or is an
// empty key.
raw::Status::Err => Err(RedisError::Str("Error while removing key expire")),
}
}

pub fn write(&self, val: &str) -> RedisResult {
let val_str = RedisString::create(self.ctx, val);
match raw::string_set(self.key_inner, val_str.inner) {
Expand Down

0 comments on commit a85ce49

Please sign in to comment.