Struct redis_module::key::RedisKeyWritable
source · [−]pub struct RedisKeyWritable { /* private fields */ }
Expand description
RedisKeyWritable
is an abstraction over a Redis key that allows read and
write operations.
Implementations
sourceimpl RedisKeyWritable
impl RedisKeyWritable
pub fn open(ctx: *mut RedisModuleCtx, key: &RedisString) -> Self
sourcepub fn read(&self) -> Result<Option<String>, RedisError>
pub fn read(&self) -> Result<Option<String>, RedisError>
Detects whether the value stored in a Redis key is empty.
Note that an empty key can be reliably detected by looking for a null as you open the key in read mode, but when asking for write Redis returns a non-null pointer to allow us to write to even an empty key, so we have to check the key’s value instead.
pub fn hash_set(&self, field: &str, value: RedisString) -> Status
pub fn hash_del(&self, field: &str) -> Status
pub fn hash_get(&self, field: &str) -> Result<Option<RedisString>, RedisError>
sourcepub fn hash_get_multi<'a, A, B>(
&self,
fields: &'a [A]
) -> Result<HMGetResult<'a, A, B>, RedisError> where
A: Into<Vec<u8>> + Clone,
RedisString: Into<B>,
pub fn hash_get_multi<'a, A, B>(
&self,
fields: &'a [A]
) -> Result<HMGetResult<'a, A, B>, RedisError> where
A: Into<Vec<u8>> + Clone,
RedisString: Into<B>,
Returns the values associated with the specified fields in the hash stored at this key.
pub fn list_push_head(&self, element: RedisString) -> Status
pub fn list_push_tail(&self, element: RedisString) -> Status
pub fn list_pop_head(&self) -> Option<RedisString>
pub fn list_pop_tail(&self) -> Option<RedisString>
pub fn set_expire(&self, expire: Duration) -> RedisResult
pub fn write(&self, val: &str) -> RedisResult
sourcepub fn delete(&self) -> RedisResult
pub fn delete(&self) -> RedisResult
Panics
Will panic if RedisModule_DeleteKey
is missing in redismodule.h
sourcepub fn key_type(&self) -> KeyType
pub fn key_type(&self) -> KeyType
Panics
Will panic if RedisModule_KeyType
is missing in redismodule.h
pub fn is_empty(&self) -> bool
pub fn open_with_redis_string(
ctx: *mut RedisModuleCtx,
key: *mut RedisModuleString
) -> Self
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for RedisKeyWritable
impl !Send for RedisKeyWritable
impl !Sync for RedisKeyWritable
impl Unpin for RedisKeyWritable
impl UnwindSafe for RedisKeyWritable
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more