Skip to main content

Dict

Struct Dict 

Source
pub struct Dict { /* private fields */ }
Expand description

High-performance in-memory dictionary

The core storage structure that holds all key-value pairs in memory. Uses SwissTable (hashbrown) with AHash for fast lookups and supports all Redis-compatible operations.

Implementations§

Source§

impl Dict

Source

pub fn get(&self, k: &[u8]) -> Option<Value>

Get a value by key (immutable reference)

§Arguments
  • k - Key to lookup as byte slice
§Returns
  • Some(&Value) if key exists
  • None if key doesn’t exist
Source

pub fn set(&self, k: Bytes, v: Value)

Set a key-value pair

Inserts or updates a key with the given value. If key already exists, the old value is replaced.

§Arguments
  • k - Key as owned Bytes
  • v - Value to store
Source

pub fn del(&self, k: &[u8]) -> bool

Delete a key

Removes the key and its associated value from the dictionary.

§Arguments
  • k - Key to delete as byte slice
§Returns
  • true if key existed and was deleted
  • false if key didn’t exist
Source

pub fn rename(&self, from: Bytes, to: Bytes) -> bool

Rename a key

Moves the value from the old key to the new key. The old key is deleted and the new key gets the value.

§Arguments
  • from - Current key name as owned Bytes
  • to - New key name as owned Bytes
§Returns
  • true if rename was successful
  • false if source key didn’t exist
Source

pub fn exists(&self, k: &[u8]) -> bool

Check if a key exists

Tests for key existence without retrieving the value.

§Arguments
  • k - Key to check as byte slice
§Returns
  • true if key exists
  • false if key doesn’t exist
Source

pub fn incr(&self, k: &[u8]) -> i64

Atomically increment an integer-like value stored under key, creating it if missing

Trait Implementations§

Source§

impl Default for Dict

Source§

fn default() -> Dict

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Dict

§

impl Freeze for Dict

§

impl Send for Dict

§

impl Sync for Dict

§

impl Unpin for Dict

§

impl UnsafeUnpin for Dict

§

impl UnwindSafe for Dict

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.