[−][src]Struct iredismodule::key::WriteKey
Repersent a Redis key with read and write permision
create with ctx.open_write_key
Implementations
impl WriteKey
[src]
pub fn new(ctx: *mut RedisModuleCtx, keyname: &RStr) -> Self
[src]
pub fn set_value<T>(
&self,
redis_type: &RType<T>,
value: T
) -> Result<&mut T, Error>
[src]
&self,
redis_type: &RType<T>,
value: T
) -> Result<&mut T, Error>
Set the specified module type object as the value of the key, deleting the old value if any.
pub fn replace_value<T>(
&self,
redis_type: &RType<T>,
value: T
) -> Result<(&mut T, Box<T>), Error>
[src]
&self,
redis_type: &RType<T>,
value: T
) -> Result<(&mut T, Box<T>), Error>
Replace the value assigned to a module type.
The key must be open for writing, have an existing value, and have a moduleType that matches the one specified by the caller.
Unlike WriteKey::set_value
which will free the old value, this function
simply swaps the old value with the new value.
The function returns Ok on success, Err on errors such as:
- Key is not opened for writing.
- Key is not a module data type key.
- Key is a module datatype other than 'mt'.
If old_value is non-NULL, the old value is returned by reference.
pub fn delete(&self) -> Result<(), Error>
[src]
Remove the key, and setup the key to accept new writes as an empty key (that will be created on demand).
pub fn unlink(&self) -> Result<(), Error>
[src]
Unlink the key (that is delete it in a non-blocking way, not reclaiming memory immediately) and setup the key to accept new writes as an empty key (that will be created on demand).
pub fn set_expire(&self, expire_ms: Duration) -> Result<(), Error>
[src]
Set new expire for the key. If the special expire REDISMODULE_NO_EXPIRE is set, the expire is cancelled if there was one (the same as the PERSIST command). Note that the expire must be provided as a positive integer representing the number of milliseconds of TTL the key should have.
pub fn string_set(&self, value: &RStr) -> Result<(), Error>
[src]
Set the specified string 'str' as the value of the key, deleting the old value if any.
pub fn list_push(
&self,
position: ListPosition,
value: &RStr
) -> Result<(), Error>
[src]
&self,
position: ListPosition,
value: &RStr
) -> Result<(), Error>
Push an element into a list
pub fn list_pop(&self, pos: ListPosition) -> Result<RString, Error>
[src]
Pop an element from the list, and returns it.
pub fn hash_set(
&self,
flag: Option<HashSetFlag>,
field: &RStr,
value: Option<&RStr>
) -> Result<(), Error>
[src]
&self,
flag: Option<HashSetFlag>,
field: &RStr,
value: Option<&RStr>
) -> Result<(), Error>
Set the field of the specified hash field to the specified value.
If value is none, it will clear the field.
pub fn zset_add(
&self,
score: f64,
ele: &RStr,
flag: Option<ZaddInputFlag>
) -> Result<ZaddOuputFlag, Error>
[src]
&self,
score: f64,
ele: &RStr,
flag: Option<ZaddInputFlag>
) -> Result<ZaddOuputFlag, Error>
Add a new element into a sorted set, with the specified 'score'. If the element already exists, the score is updated.
pub fn zset_incrby(
&self,
ele: &RStr,
score: f64,
flag: Option<ZaddInputFlag>
) -> Result<(ZaddOuputFlag, f64), Error>
[src]
&self,
ele: &RStr,
score: f64,
flag: Option<ZaddInputFlag>
) -> Result<(ZaddOuputFlag, f64), Error>
This function works exactly like WriteKey::zset_add
, but instead of setting
a new score, the score of the existing element is incremented, or if the
element does not already exist, it is added assuming the old score was
zero.
pub fn zset_rem(&self, ele: &RStr) -> Result<bool, Error>
[src]
Remove the specified element from the sorted set.
The bool indicate Whether the element was removed
pub fn zset_score(&self, ele: &RStr) -> Result<f64, Error>
[src]
On success retrieve the double score associated at the sorted set element 'ele'.
pub fn set_lfu(&self, freq: u64) -> Result<(), Error>
[src]
Set the key access frequency. only relevant if the server's maxmemory policy is LFU based.
pub fn set_lru(&self, time_ms: Duration) -> Result<(), Error>
[src]
Set the key last access time for LRU based eviction. not relevent if the servers's maxmemory policy is LFU based. Value is idle time in milliseconds.
Methods from Deref<Target = ReadKey>
pub fn is_empty(&self) -> bool
[src]
Where the key pointer is NULL
pub fn get_value<T>(
&self,
redis_type: &RType<T>
) -> Result<Option<&mut T>, Error>
[src]
&self,
redis_type: &RType<T>
) -> Result<Option<&mut T>, Error>
Assuming get_type
returned REDISMODULE_KEYTYPE_MODULE on
the key, returns the module type low-level value stored at key, as
it was set by the user via set_value
.
pub fn check_type(&self, expect_type: KeyType) -> Result<bool, Error>
[src]
Check the key type.
The bool indicate whether the value is empty
pub fn check_module_type<T>(&self, redis_type: &RType<T>) -> Result<bool, Error>
[src]
Check the type of key is KeyType::Module
and the it's specifi module type is redis_type
The bool indicate whether the value is empty
pub fn string_get(&self) -> Result<RString, Error>
[src]
pub fn hash_get(&self, field: &RStr) -> Result<Option<RString>, Error>
[src]
Get fields from an hash value.
pub fn hash_check(&self, field: &RStr) -> Result<bool, Error>
[src]
Check fileds exists
pub fn zset_score_range(
&self,
dir: ZsetRangeDirection,
min: f64,
max: f64,
min_exclude: bool,
max_exclude: bool
) -> Result<Vec<(RString, f64)>, Error>
[src]
&self,
dir: ZsetRangeDirection,
min: f64,
max: f64,
min_exclude: bool,
max_exclude: bool
) -> Result<Vec<(RString, f64)>, Error>
Get range of zset (key, score) pairs order by score
pub fn zset_lex_range(
&self,
dir: ZsetRangeDirection,
min: &RStr,
max: &RStr
) -> Result<Vec<(RString, f64)>, Error>
[src]
&self,
dir: ZsetRangeDirection,
min: &RStr,
max: &RStr
) -> Result<Vec<(RString, f64)>, Error>
Get range of zset (key, score) pairs order by lex
pub fn value_length(&self) -> usize
[src]
Return the length of the value associated with the key.
For strings this is the length of the string. For all the other types is the number of elements (just counting keys for hashes).
pub fn get_expire(&self) -> Option<Duration>
[src]
Return the key expire value, as milliseconds of remaining TTL.
If no TTL is associated with the key or if the key is empty, None is returned.
pub fn get_type(&self) -> KeyType
[src]
Return the type of the key.
If the key pointer is NULL then KeyType::EMPTY
is returned.
pub fn scan<T>(
&self,
cursor: &ScanCursor,
callback: RedisModuleScanKeyCB,
privdata: Option<T>
) -> Result<(), Error>
[src]
&self,
cursor: &ScanCursor,
callback: RedisModuleScanKeyCB,
privdata: Option<T>
) -> Result<(), Error>
Scan api that allows a module to scan the elements in a hash, set or sorted set key
pub fn get_keyname(&self) -> RStr
[src]
Returns the name of the key
pub fn signal_ready(&self)
[src]
This function is used in order to potentially unblock a client blocked
on keys with Context::block_client_on_keys
. When this function is called,
all the clients blocked for this key will get their reply callback called,
and if the callback returns REDISMODULE_OK the client will be unblocked.
pub fn get_lfu(&self) -> Result<u64, Error>
[src]
Gets the key access frequency or -1 if the server's eviction policy is not LFU based.
pub fn get_lru(&self) -> Result<Duration, Error>
[src]
Gets the key last access time.
Value is idletime in milliseconds or -1 if the server's eviction policy is LFU based.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for WriteKey
impl !Send for WriteKey
impl !Sync for WriteKey
impl Unpin for WriteKey
impl UnwindSafe for WriteKey
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,