redis-cache

Crates.ioredis-cache
lib.rsredis-cache
version0.3.0
sourcesrc
created_at2020-08-30 20:35:55.838433
updated_at2020-12-06 14:13:46.92974
descriptionA shared cache designed for casbin-rs
homepagehttps://casbin.org/
repositoryhttps://github.com/casbin-rs/redis-cache
max_upload_size
id282827
size5,801
Cheng JIANG (GopherJ)

documentation

README

Redis Cache

A shared memory cache for casbin-rs, backed by redis.

Installation

[dependencies]
casbin = { version = "2.0.1", default-features = false, features = ["runtime-async-std", "logging", "cached"] }
redis-cache = { version = "0.2.0" }
async-std = { version = "1.5.0", features = ["attributes"] }

Getting started

use casbin::prelude::*;
use redis_cache::RedisCache;

#[async_std::main]
async fn main() -> Result<()> {
    let mut e = CachedEnforcer::new("examples/rbac_with_domains_model.conf", "examples/rbac_with_domains_policy.csv").await?;
    e.enable_log(true);

    let redis_cache: RedisCache<u64, bool> = RedisCache::new("redis://localhost:6379/1");

    e.set_cache(Box::new(redis_cache));
    e.enforce_mut(("alice", "domain1", "data1", "read"))?;
}
Commit count: 7

cargo fmt