doido-cache 0.0.12

Named cache stores, TTL — memory/Redis/Memcached backends in ActiveSupport::Cache fashion for Doido.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use doido_cache::codec::{decode, encode};
use serde_json::json;

#[test]
fn round_trips_with_and_without_compression() {
    let value = json!({ "data": "x".repeat(2000), "n": 7 });

    let raw = encode(&value, false);
    let compressed = encode(&value, true);
    assert!(compressed.len() < raw.len(), "gzip shrinks repetitive data");

    assert_eq!(decode(&raw, false).unwrap(), value);
    assert_eq!(decode(&compressed, true).unwrap(), value);
}