Skip to main content

Crate backbone_cache

Crate backbone_cache 

Source
Expand description

Backbone Framework Cache Module

Provides caching functionality with Redis and in-memory support.

§Features

  • Redis Backend: Distributed caching with Redis
  • Memory Backend: In-process caching for development/testing
  • TTL Support: Time-to-live for cache entries
  • Async/Await: Full async support with tokio
  • Generic Types: Cache any serializable data

§Quick Start

use backbone_cache::{Cache, RedisCache};
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize)]
struct User {
    id: String,
    name: String,
}

// Redis cache
let cache = RedisCache::new("redis://localhost:6379").await?;

// Store user in cache
let user = User { id: "123".to_string(), name: "John".to_string() };
cache.set("user:123", &user, Some(3600)).await?;

// Retrieve user from cache
let cached_user: Option<User> = cache.get("user:123").await?;

Re-exports§

pub use traits::*;
pub use memory::*;
pub use redis::*;

Modules§

memory
In-memory cache implementation
redis
Redis cache implementation
traits
Cache trait definitions

Structs§

CacheConfig
Cache configuration
CacheKey
Cache key builder utilities

Enums§

CacheError
Cache error types

Constants§

DEFAULT_TTL
Default cache TTL in seconds (1 hour)
VERSION
Cache module version

Type Aliases§

CacheResult
Result type for cache operations