pub enum CacheDriver {
Memory,
Redis,
RedisCluster,
Memcached,
DynamoDb,
}Expand description
Where cached values live.
The enum names every store this crate knows how to build, whether or not
the cargo feature behind it is on. That is deliberate: CACHE_DRIVER=redis
in a build without the redis-driver feature is a build mistake, and
it deserves a message saying so — not the same “unknown driver” message a
typo gets.
use rainier_cache::CacheDriver;
use rainier_support::Setting;
assert_eq!(CacheDriver::parse("redis-cluster").unwrap(), CacheDriver::RedisCluster);
assert!(CacheDriver::parse("redys").is_err());Variants§
Memory
This process only. Fast, and shares nothing between instances.
The default because it needs no server, and the right choice for
tests and single-process development. Anything cached for
correctness rather than for speed is wrong in it — a rate-limit
counter becomes N × its limit across N instances, and a lock is
not a lock.
Redis
One Redis server, or a Sentinel-fronted primary.
RedisCluster
A sharded Redis Cluster. Keys distribute across the seed nodes.
Memcached
Memcached over its text protocol.
DynamoDb
DynamoDB, with TTL doing the expiry. No server to run.
Implementations§
Source§impl CacheDriver
impl CacheDriver
Source§impl CacheDriver
impl CacheDriver
Whether this driver is shared between instances of the application.
The question a production checklist is really asking. A rate limiter, a
lock, or a cached authorisation decision needs true here; a memoised
computation does not.
Trait Implementations§
Source§impl AsRef<str> for CacheDriver
impl AsRef<str> for CacheDriver
Source§impl Clone for CacheDriver
impl Clone for CacheDriver
Source§fn clone(&self) -> CacheDriver
fn clone(&self) -> CacheDriver
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more