Skip to main content

Crate not_redis

Crate not_redis 

Source
Expand description

§not_redis

A Redis-compatible in-memory data structure library for Rust.

not_redis provides Redis-like APIs without the networking overhead, external service dependencies, or operational complexity of running a Redis server.

§Features

  • Zero-config: Embeddable Redis-compatible storage
  • Thread-safe: Concurrent access via Tokio and DashMap
  • RESP-compatible: Data types and command semantics compatible with Redis
  • In-process: No network overhead - runs in your application

§Supported Commands

  • Strings: GET, SET, DEL, EXISTS, EXPIRE, TTL, PERSIST
  • Hashes: HSET, HGET, HGETALL, HDEL
  • Lists: LPUSH, RPUSH, LLEN
  • Sets: SADD, SMEMBERS
  • Utilities: PING, ECHO, DBSIZE, FLUSHDB

§Example

use not_redis::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut client = Client::new();
    client.start().await;

    // String operations
    client.set("user:1:name", "Alice").await?;
    let name: String = client.get("user:1:name").await?;

    // Hash operations
    client.hset("user:1", "email", "alice@example.com").await?;
    let email: String = client.hget("user:1", "email").await?;

    // Expiration
    client.expire("user:1", 60).await?;
    let ttl: i64 = client.ttl("user:1").await?;

    Ok(())
}

Structs§

Client
A Redis client for executing commands against an in-memory store.
StorageEngine
The core storage engine for the Redis-like store.
StoredValue
A value stored in the storage engine with optional expiration.

Enums§

RedisData
Internal data types stored in the engine.
RedisError
Error type for Redis operations.
Value
Represents a value stored in or returned from Redis.

Traits§

FromRedisValue
A trait for converting Redis values into Rust types.
ToRedisArgs
A trait for converting values into Redis command arguments.

Type Aliases§

RedisResult
A specialized Result type for Redis operations.
StreamEntry
Represents a single entry in a Redis stream.