pub struct RedisKey { /* private fields */ }Implementations§
Source§impl RedisKey
impl RedisKey
pub fn open(ctx: *mut RedisModuleCtx, key: &RedisString) -> Self
pub fn open_with_flags( ctx: *mut RedisModuleCtx, key: &RedisString, flags: KeyFlags, ) -> Self
Sourcepub const unsafe fn from_raw_parts(
ctx: *mut RedisModuleCtx,
key_inner: *mut RedisModuleKey,
) -> Self
pub const unsafe fn from_raw_parts( ctx: *mut RedisModuleCtx, key_inner: *mut RedisModuleKey, ) -> Self
Construct a new RedisKey from a pointer to a redismodule context and a key.
§Safety
The caller must ensure:
- The
ctxpointer remains valid for the lifetime of theRedisKey. - The
key_innerpointer remains valid for the lifetime of theRedisKey.
Sourcepub fn to_raw_parts(self) -> (*mut RedisModuleCtx, *mut RedisModuleKey)
pub fn to_raw_parts(self) -> (*mut RedisModuleCtx, *mut RedisModuleKey)
Decomposes a RedisKey into its raw components: (redismodule context pointer, key pointer).
After calling this function, the caller is responsible for cleaning up the raw key previously managed by the RedisKey.
The only way to do this safely is to convert the raw redismodule context and key pointers back into a RedisKey with
the from_raw_parts function, allowing the destructor to perform the cleanup.
Sourcepub fn get_value<T>(
&self,
redis_type: &RedisType,
) -> Result<Option<&T>, RedisError>
pub fn get_value<T>( &self, redis_type: &RedisType, ) -> Result<Option<&T>, RedisError>
§Panics
Will panic if RedisModule_ModuleTypeGetValue 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 read(&self) -> Result<Option<&[u8]>, RedisError>
pub fn hash_get(&self, field: &str) -> Result<Option<RedisString>, RedisError>
Sourcepub fn hash_get_multi<'a, A, B>(
&self,
fields: &'a [A],
) -> Result<Option<HMGetResult<'a, A, B>>, RedisError>
pub fn hash_get_multi<'a, A, B>( &self, fields: &'a [A], ) -> Result<Option<HMGetResult<'a, A, B>>, RedisError>
Returns the values associated with the specified fields in the hash stored at this key.
The result will be None if the key does not exist.