[{"data":1,"prerenderedAt":1249},["ShallowReactive",2],{"$fFtEBuGijRRKx1Ke2aMo_7TuI1v-ac6LnO6wJEIPHOAU":3},{"slug":4,"title":5,"description":6,"source":7,"document":8,"toc":1233,"editUrl":1243,"prev":1244,"next":1247},"techniques\u002Fcaching","Caching (Redis)","Cache anything with ferrite-cache-redis CacheService and cache responses with interceptors.","---\ntitle: Caching (Redis)\ndescription: Cache anything with ferrite-cache-redis CacheService and cache responses with interceptors.\n---\n\n# Caching (Redis)\n\n`ferrite-cache-redis` is a small, typed Redis client: get\u002Fset with TTLs, counters, key listing, and a `roundtrip` helper for tests.\n\n## Enable it\n\n```cargo\nfr add cache-redis\n```\n\n```rust\n#[module(imports = [CacheModule])]\npub struct AppModule;\n```\n\n## `CacheService`\n\n```rust\nuse ferrite_cache_redis::CacheService;\nuse serde::{Deserialize, Serialize};\n\n#[derive(Serialize, Deserialize, Clone)]\npub struct Profile { pub name: String }\n\n#[injectable]\npub struct ProfilesService {\n    cache: CacheService,\n}\n\nimpl ProfilesService {\n    #[inject]\n    pub fn new(cache: CacheService) -> Self {\n        Self { cache }\n    }\n\n    pub async fn get_profile(&self, id: i64) -> Result\u003COption\u003CProfile>, CacheError> {\n        self.cache.get::\u003CProfile>(&format!(\"profile:{id}\")).await\n    }\n\n    pub async fn set_profile(&self, id: i64, profile: &Profile) -> Result\u003C(), CacheError> {\n        self.cache\n            .set_with_ttl(&format!(\"profile:{id}\"), profile, 600)\n            .await\n    }\n}\n```\n\n### API\n\n| Method | Description |\n| --- | --- |\n| `get\u003CT: DeserializeOwned>(key)` | Read and deserialize |\n| `set\u003CT: Serialize>(key, value)` | Write |\n| `set_with_ttl\u003CT>(key, value, secs)` | Write with expiry |\n| `delete(key)` | Remove |\n| `expire(key, secs)` | Set TTL on existing key |\n| `ttl(key)` | Remaining TTL |\n| `keys(pattern)` | Glob match |\n| `incr(key)` \u002F `decr(key)` \u002F `incr_by(key, n)` | Counters |\n| `exists(key)` | Presence |\n| `clear_all()` | Flush the configured DB |\n| `prefix()` \u002F `key_for(suffix)` | Key namespace helpers |\n| `roundtrip\u003CT>()` | Test helper |\n\n`CacheError` converts from `redis::RedisError` and `serde_json::Error`.\n\n## Caching HTTP responses with an interceptor\n\nCache the whole handler result:\n\n```rust\nuse ferrite_framework::{Interceptor, RequestCtx, Next, Response, async_trait};\nuse ferrite_cache_redis::CacheService;\nuse ferrite_framework::injectable;\nuse std::sync::Arc;\n\n#[injectable]\npub struct ResponseCacheInterceptor {\n    cache: CacheService,\n}\n\nimpl ResponseCacheInterceptor {\n    #[inject]\n    pub fn new(cache: CacheService) -> Self {\n        Self { cache }\n    }\n}\n\n#[async_trait]\nimpl Interceptor for ResponseCacheInterceptor {\n    async fn intercept(&self, ctx: RequestCtx, next: Next) -> Response {\n        let key = self.cache.key_for(&ctx.uri().to_string());\n\n        if let Ok(Some(body)) = self.cache.get::\u003CVec\u003Cu8>>(&key).await {\n            return axum::response::Response::new(body.into());\n        }\n\n        let response = next(ctx).await;\n        \u002F\u002F optionally cache 200 responses (serialize the body)\n        let body = response.body().to_owned();\n        let _ = self.cache.set(&key, &body.to_vec()).await;\n        Response::new(body)\n    }\n}\n```\n\n## Key namespacing\n\n`CacheService` builds namespaced keys so services don't collide:\n\n```rust\ncache.key_for(\"users:1\");       \u002F\u002F e.g. \"ferrite:users:1\"\ncache.key_for(&request_key);    \u002F\u002F helper for request-scoped keys\n```\n\n## Notes\n\n- All methods are async — they run on the Tokio runtime with the configured Redis connection.\n- Use `fr test --coverage` + `roundtrip\u003CT>()` for quick serialization smoke tests of your cache types.\n\n## Next steps\n\n- [Rate limiting](\u002Fdocs\u002Ftechniques\u002Frate-limiting).\n- [Interceptors](\u002Fdocs\u002Foverview\u002Finterceptors).",{"frontmatter":9,"meta":10,"nodes":38},{"title":5,"description":6},{"toc":11},{"title":12,"searchDepth":13,"depth":14,"links":15},"On This Page",2,3,[16,19,26,29,32,35],{"id":17,"depth":13,"text":18},"enable-it","Enable it",{"id":20,"depth":13,"text":21,"children":22},"cacheservice","CacheService",[23],{"id":24,"depth":14,"text":25},"cacheservice-api","API",{"id":27,"depth":13,"text":28},"caching-http-responses-with-an-interceptor","Caching HTTP responses with an interceptor",{"id":30,"depth":13,"text":31},"key-namespacing","Key namespacing",{"id":33,"depth":13,"text":34},"notes","Notes",{"id":36,"depth":13,"text":37},"next-steps","Next steps",[39,43,55,58,67,112,116,502,505,655,667,669,672,1149,1151,1156,1197,1199,1216,1218],[40,41,5],"h1",{"id":42},"caching-redis",[44,45,46,50,51,54],"p",{},[47,48,49],"code",{},"ferrite-cache-redis"," is a small, typed Redis client: get\u002Fset with TTLs, counters, key listing, and a ",[47,52,53],{},"roundtrip"," helper for tests.",[56,57,18],"h2",{"id":17},[59,60,63],"pre",{"language":61,"class":62},"cargo","shiki dark:github-dark",[47,64,66],{"class":65},"language-cargo","fr add cache-redis",[59,68,71],{"language":69,"class":70},"rust","shiki shiki-themes github-light github-dark dark:github-dark",[47,72,74,97,98],{"class":73},"language-rust",[75,76,79,83,87,90,94],"span",{"class":77,"style":78},"line","display: inline",[75,80,82],{"style":81},"color:#24292E;--shiki-dark:#E1E4E8","#[module(imports ",[75,84,86],{"style":85},"color:#D73A49;--shiki-dark:#F97583","=",[75,88,89],{"style":81}," [",[75,91,93],{"style":92},"color:#6F42C1;--shiki-dark:#B392F0","CacheModule",[75,95,96],{"style":81},"])]","\n",[75,99,100,103,106,109],{"class":77,"style":78},[75,101,102],{"style":85},"pub",[75,104,105],{"style":85}," struct",[75,107,108],{"style":92}," AppModule",[75,110,111],{"style":81},";",[56,113,114],{"id":20},[47,115,21],{},[59,117,118],{"language":69,"class":70},[47,119,120,97,135,97,159,97,161,97,180,97,206,97,208,97,213,97,225,97,238,97,243,97,245,97,254,97,259,97,289,97,297,97,302,97,304,97,360,97,402,97,406,97,408,97,454,97,462,97,489,97,494,97,498],{"class":73},[75,121,122,125,128,131,133],{"class":77,"style":78},[75,123,124],{"style":85},"use",[75,126,127],{"style":92}," ferrite_cache_redis",[75,129,130],{"style":85},"::",[75,132,21],{"style":92},[75,134,111],{"style":81},[75,136,137,139,142,144,147,150,153,156],{"class":77,"style":78},[75,138,124],{"style":85},[75,140,141],{"style":92}," serde",[75,143,130],{"style":85},[75,145,146],{"style":81},"{",[75,148,149],{"style":92},"Deserialize",[75,151,152],{"style":81},", ",[75,154,155],{"style":92},"Serialize",[75,157,158],{"style":81},"};",[75,160],{"class":77,"style":78},[75,162,163,166,168,170,172,174,177],{"class":77,"style":78},[75,164,165],{"style":81},"#[derive(",[75,167,155],{"style":92},[75,169,152],{"style":81},[75,171,149],{"style":92},[75,173,152],{"style":81},[75,175,176],{"style":92},"Clone",[75,178,179],{"style":81},")]",[75,181,182,184,186,189,192,194,197,200,203],{"class":77,"style":78},[75,183,102],{"style":85},[75,185,105],{"style":85},[75,187,188],{"style":92}," Profile",[75,190,191],{"style":81}," { ",[75,193,102],{"style":85},[75,195,196],{"style":81}," name",[75,198,199],{"style":85},":",[75,201,202],{"style":92}," String",[75,204,205],{"style":81}," }",[75,207],{"class":77,"style":78},[75,209,210],{"class":77,"style":78},[75,211,212],{"style":81},"#[injectable]",[75,214,215,217,219,222],{"class":77,"style":78},[75,216,102],{"style":85},[75,218,105],{"style":85},[75,220,221],{"style":92}," ProfilesService",[75,223,224],{"style":81}," {",[75,226,227,230,232,235],{"class":77,"style":78},[75,228,229],{"style":81},"    cache",[75,231,199],{"style":85},[75,233,234],{"style":92}," CacheService",[75,236,237],{"style":81},",",[75,239,240],{"class":77,"style":78},[75,241,242],{"style":81},"}",[75,244],{"class":77,"style":78},[75,246,247,250,252],{"class":77,"style":78},[75,248,249],{"style":85},"impl",[75,251,221],{"style":92},[75,253,224],{"style":81},[75,255,256],{"class":77,"style":78},[75,257,258],{"style":81},"    #[inject]",[75,260,261,264,267,270,273,275,277,280,283,287],{"class":77,"style":78},[75,262,263],{"style":85},"    pub",[75,265,266],{"style":85}," fn",[75,268,269],{"style":92}," new",[75,271,272],{"style":81},"(cache",[75,274,199],{"style":85},[75,276,234],{"style":92},[75,278,279],{"style":81},") ",[75,281,282],{"style":85},"->",[75,284,286],{"style":285},"color:#005CC5;--shiki-dark:#79B8FF"," Self",[75,288,224],{"style":81},[75,290,291,294],{"class":77,"style":78},[75,292,293],{"style":285},"        Self",[75,295,296],{"style":81}," { cache }",[75,298,299],{"class":77,"style":78},[75,300,301],{"style":81},"    }",[75,303],{"class":77,"style":78},[75,305,306,308,311,313,316,319,322,325,328,330,333,335,337,340,343,346,348,351,354,357],{"class":77,"style":78},[75,307,263],{"style":85},[75,309,310],{"style":85}," async",[75,312,266],{"style":85},[75,314,315],{"style":92}," get_profile",[75,317,318],{"style":81},"(",[75,320,321],{"style":85},"&",[75,323,324],{"style":285},"self",[75,326,327],{"style":81},", id",[75,329,199],{"style":85},[75,331,332],{"style":92}," i64",[75,334,279],{"style":81},[75,336,282],{"style":85},[75,338,339],{"style":92}," Result",[75,341,342],{"style":81},"\u003C",[75,344,345],{"style":92},"Option",[75,347,342],{"style":81},[75,349,350],{"style":92},"Profile",[75,352,353],{"style":81},">, ",[75,355,356],{"style":92},"CacheError",[75,358,359],{"style":81},"> {",[75,361,362,365,368,371,373,376,378,380,382,385,387,390,392,396,399],{"class":77,"style":78},[75,363,364],{"style":285},"        self",[75,366,367],{"style":85},".",[75,369,370],{"style":81},"cache",[75,372,367],{"style":85},[75,374,375],{"style":92},"get",[75,377,130],{"style":85},[75,379,342],{"style":81},[75,381,350],{"style":92},[75,383,384],{"style":81},">(",[75,386,321],{"style":85},[75,388,389],{"style":92},"format!",[75,391,318],{"style":81},[75,393,395],{"style":394},"color:#032F62;--shiki-dark:#9ECBFF","\"profile:{id}\"",[75,397,398],{"style":81},"))",[75,400,401],{"style":85},".await",[75,403,404],{"class":77,"style":78},[75,405,301],{"style":81},[75,407],{"class":77,"style":78},[75,409,410,412,414,416,419,421,423,425,427,429,431,434,436,439,441,443,445,447,450,452],{"class":77,"style":78},[75,411,263],{"style":85},[75,413,310],{"style":85},[75,415,266],{"style":85},[75,417,418],{"style":92}," set_profile",[75,420,318],{"style":81},[75,422,321],{"style":85},[75,424,324],{"style":285},[75,426,327],{"style":81},[75,428,199],{"style":85},[75,430,332],{"style":92},[75,432,433],{"style":81},", profile",[75,435,199],{"style":85},[75,437,438],{"style":85}," &",[75,440,350],{"style":92},[75,442,279],{"style":81},[75,444,282],{"style":85},[75,446,339],{"style":92},[75,448,449],{"style":81},"\u003C(), ",[75,451,356],{"style":92},[75,453,359],{"style":81},[75,455,456,458,460],{"class":77,"style":78},[75,457,364],{"style":285},[75,459,367],{"style":85},[75,461,370],{"style":81},[75,463,464,467,470,472,474,476,478,480,483,486],{"class":77,"style":78},[75,465,466],{"style":85},"            .",[75,468,469],{"style":92},"set_with_ttl",[75,471,318],{"style":81},[75,473,321],{"style":85},[75,475,389],{"style":92},[75,477,318],{"style":81},[75,479,395],{"style":394},[75,481,482],{"style":81},"), profile, ",[75,484,485],{"style":285},"600",[75,487,488],{"style":81},")",[75,490,491],{"class":77,"style":78},[75,492,493],{"style":85},"            .await",[75,495,496],{"class":77,"style":78},[75,497,301],{"style":81},[75,499,500],{"class":77,"style":78},[75,501,242],{"style":81},[503,504,25],"h3",{"id":24},[506,507,508,521],"table",{},[509,510,511],"thead",{},[512,513,514,518],"tr",{},[515,516,517],"th",{},"Method",[515,519,520],{},"Description",[522,523,524,535,545,555,565,575,585,595,612,622,632,645],"tbody",{},[512,525,526,532],{},[527,528,529],"td",{},[47,530,531],{},"get\u003CT: DeserializeOwned>(key)",[527,533,534],{},"Read and deserialize",[512,536,537,542],{},[527,538,539],{},[47,540,541],{},"set\u003CT: Serialize>(key, value)",[527,543,544],{},"Write",[512,546,547,552],{},[527,548,549],{},[47,550,551],{},"set_with_ttl\u003CT>(key, value, secs)",[527,553,554],{},"Write with expiry",[512,556,557,562],{},[527,558,559],{},[47,560,561],{},"delete(key)",[527,563,564],{},"Remove",[512,566,567,572],{},[527,568,569],{},[47,570,571],{},"expire(key, secs)",[527,573,574],{},"Set TTL on existing key",[512,576,577,582],{},[527,578,579],{},[47,580,581],{},"ttl(key)",[527,583,584],{},"Remaining TTL",[512,586,587,592],{},[527,588,589],{},[47,590,591],{},"keys(pattern)",[527,593,594],{},"Glob match",[512,596,597,609],{},[527,598,599,602,603,602,606],{},[47,600,601],{},"incr(key)"," \u002F ",[47,604,605],{},"decr(key)",[47,607,608],{},"incr_by(key, n)",[527,610,611],{},"Counters",[512,613,614,619],{},[527,615,616],{},[47,617,618],{},"exists(key)",[527,620,621],{},"Presence",[512,623,624,629],{},[527,625,626],{},[47,627,628],{},"clear_all()",[527,630,631],{},"Flush the configured DB",[512,633,634,642],{},[527,635,636,602,639],{},[47,637,638],{},"prefix()",[47,640,641],{},"key_for(suffix)",[527,643,644],{},"Key namespace helpers",[512,646,647,652],{},[527,648,649],{},[47,650,651],{},"roundtrip\u003CT>()",[527,653,654],{},"Test helper",[44,656,657,659,660,663,664,367],{},[47,658,356],{}," converts from ",[47,661,662],{},"redis::RedisError"," and ",[47,665,666],{},"serde_json::Error",[56,668,28],{"id":27},[44,670,671],{},"Cache the whole handler result:",[59,673,674],{"language":69,"class":70},[47,675,676,97,708,97,720,97,731,97,750,97,752,97,756,97,767,97,777,97,781,97,783,97,791,97,795,97,817,97,823,97,827,97,831,97,833,97,838,97,852,97,893,97,938,97,940,97,995,97,1027,97,1032,97,1034,97,1053,97,1059,97,1086,97,1129,97,1141,97,1145],{"class":73},[75,677,678,680,683,685,687,690,692,695,697,700,702,705],{"class":77,"style":78},[75,679,124],{"style":85},[75,681,682],{"style":92}," ferrite_framework",[75,684,130],{"style":85},[75,686,146],{"style":81},[75,688,689],{"style":92},"Interceptor",[75,691,152],{"style":81},[75,693,694],{"style":92},"RequestCtx",[75,696,152],{"style":81},[75,698,699],{"style":92},"Next",[75,701,152],{"style":81},[75,703,704],{"style":92},"Response",[75,706,707],{"style":81},", async_trait};",[75,709,710,712,714,716,718],{"class":77,"style":78},[75,711,124],{"style":85},[75,713,127],{"style":92},[75,715,130],{"style":85},[75,717,21],{"style":92},[75,719,111],{"style":81},[75,721,722,724,726,728],{"class":77,"style":78},[75,723,124],{"style":85},[75,725,682],{"style":92},[75,727,130],{"style":85},[75,729,730],{"style":81},"injectable;",[75,732,733,735,738,740,743,745,748],{"class":77,"style":78},[75,734,124],{"style":85},[75,736,737],{"style":92}," std",[75,739,130],{"style":85},[75,741,742],{"style":92},"sync",[75,744,130],{"style":85},[75,746,747],{"style":92},"Arc",[75,749,111],{"style":81},[75,751],{"class":77,"style":78},[75,753,754],{"class":77,"style":78},[75,755,212],{"style":81},[75,757,758,760,762,765],{"class":77,"style":78},[75,759,102],{"style":85},[75,761,105],{"style":85},[75,763,764],{"style":92}," ResponseCacheInterceptor",[75,766,224],{"style":81},[75,768,769,771,773,775],{"class":77,"style":78},[75,770,229],{"style":81},[75,772,199],{"style":85},[75,774,234],{"style":92},[75,776,237],{"style":81},[75,778,779],{"class":77,"style":78},[75,780,242],{"style":81},[75,782],{"class":77,"style":78},[75,784,785,787,789],{"class":77,"style":78},[75,786,249],{"style":85},[75,788,764],{"style":92},[75,790,224],{"style":81},[75,792,793],{"class":77,"style":78},[75,794,258],{"style":81},[75,796,797,799,801,803,805,807,809,811,813,815],{"class":77,"style":78},[75,798,263],{"style":85},[75,800,266],{"style":85},[75,802,269],{"style":92},[75,804,272],{"style":81},[75,806,199],{"style":85},[75,808,234],{"style":92},[75,810,279],{"style":81},[75,812,282],{"style":85},[75,814,286],{"style":285},[75,816,224],{"style":81},[75,818,819,821],{"class":77,"style":78},[75,820,293],{"style":285},[75,822,296],{"style":81},[75,824,825],{"class":77,"style":78},[75,826,301],{"style":81},[75,828,829],{"class":77,"style":78},[75,830,242],{"style":81},[75,832],{"class":77,"style":78},[75,834,835],{"class":77,"style":78},[75,836,837],{"style":81},"#[async_trait]",[75,839,840,842,845,848,850],{"class":77,"style":78},[75,841,249],{"style":85},[75,843,844],{"style":92}," Interceptor",[75,846,847],{"style":85}," for",[75,849,764],{"style":92},[75,851,224],{"style":81},[75,853,854,857,859,862,864,866,868,871,873,876,879,881,884,886,888,891],{"class":77,"style":78},[75,855,856],{"style":85},"    async",[75,858,266],{"style":85},[75,860,861],{"style":92}," intercept",[75,863,318],{"style":81},[75,865,321],{"style":85},[75,867,324],{"style":285},[75,869,870],{"style":81},", ctx",[75,872,199],{"style":85},[75,874,875],{"style":92}," RequestCtx",[75,877,878],{"style":81},", next",[75,880,199],{"style":85},[75,882,883],{"style":92}," Next",[75,885,279],{"style":81},[75,887,282],{"style":85},[75,889,890],{"style":92}," Response",[75,892,224],{"style":81},[75,894,895,898,901,903,906,908,910,912,915,917,919,922,924,927,930,932,935],{"class":77,"style":78},[75,896,897],{"style":85},"        let",[75,899,900],{"style":81}," key ",[75,902,86],{"style":85},[75,904,905],{"style":285}," self",[75,907,367],{"style":85},[75,909,370],{"style":81},[75,911,367],{"style":85},[75,913,914],{"style":92},"key_for",[75,916,318],{"style":81},[75,918,321],{"style":85},[75,920,921],{"style":81},"ctx",[75,923,367],{"style":85},[75,925,926],{"style":92},"uri",[75,928,929],{"style":81},"()",[75,931,367],{"style":85},[75,933,934],{"style":92},"to_string",[75,936,937],{"style":81},"());",[75,939],{"class":77,"style":78},[75,941,942,945,948,951,953,956,959,961,963,965,967,969,971,973,975,978,980,983,986,988,991,993],{"class":77,"style":78},[75,943,944],{"style":85},"        if",[75,946,947],{"style":85}," let",[75,949,950],{"style":92}," Ok",[75,952,318],{"style":81},[75,954,955],{"style":92},"Some",[75,957,958],{"style":81},"(body)) ",[75,960,86],{"style":85},[75,962,905],{"style":285},[75,964,367],{"style":85},[75,966,370],{"style":81},[75,968,367],{"style":85},[75,970,375],{"style":92},[75,972,130],{"style":85},[75,974,342],{"style":81},[75,976,977],{"style":92},"Vec",[75,979,342],{"style":81},[75,981,982],{"style":92},"u8",[75,984,985],{"style":81},">>(",[75,987,321],{"style":85},[75,989,990],{"style":81},"key)",[75,992,401],{"style":85},[75,994,224],{"style":81},[75,996,997,1000,1003,1005,1008,1010,1012,1014,1017,1020,1022,1025],{"class":77,"style":78},[75,998,999],{"style":85},"            return",[75,1001,1002],{"style":92}," axum",[75,1004,130],{"style":85},[75,1006,1007],{"style":92},"response",[75,1009,130],{"style":85},[75,1011,704],{"style":92},[75,1013,130],{"style":85},[75,1015,1016],{"style":92},"new",[75,1018,1019],{"style":81},"(body",[75,1021,367],{"style":85},[75,1023,1024],{"style":92},"into",[75,1026,937],{"style":81},[75,1028,1029],{"class":77,"style":78},[75,1030,1031],{"style":81},"        }",[75,1033],{"class":77,"style":78},[75,1035,1036,1038,1041,1043,1046,1049,1051],{"class":77,"style":78},[75,1037,897],{"style":85},[75,1039,1040],{"style":81}," response ",[75,1042,86],{"style":85},[75,1044,1045],{"style":92}," next",[75,1047,1048],{"style":81},"(ctx)",[75,1050,401],{"style":85},[75,1052,111],{"style":81},[75,1054,1055],{"class":77,"style":78},[75,1056,1058],{"style":1057},"color:#6A737D;--shiki-dark:#6A737D","        \u002F\u002F optionally cache 200 responses (serialize the body)",[75,1060,1061,1063,1066,1068,1071,1073,1076,1078,1080,1083],{"class":77,"style":78},[75,1062,897],{"style":85},[75,1064,1065],{"style":81}," body ",[75,1067,86],{"style":85},[75,1069,1070],{"style":81}," response",[75,1072,367],{"style":85},[75,1074,1075],{"style":92},"body",[75,1077,929],{"style":81},[75,1079,367],{"style":85},[75,1081,1082],{"style":92},"to_owned",[75,1084,1085],{"style":81},"();",[75,1087,1088,1090,1093,1095,1097,1099,1101,1103,1106,1108,1110,1113,1115,1117,1119,1122,1125,1127],{"class":77,"style":78},[75,1089,897],{"style":85},[75,1091,1092],{"style":81}," _ ",[75,1094,86],{"style":85},[75,1096,905],{"style":285},[75,1098,367],{"style":85},[75,1100,370],{"style":81},[75,1102,367],{"style":85},[75,1104,1105],{"style":92},"set",[75,1107,318],{"style":81},[75,1109,321],{"style":85},[75,1111,1112],{"style":81},"key, ",[75,1114,321],{"style":85},[75,1116,1075],{"style":81},[75,1118,367],{"style":85},[75,1120,1121],{"style":92},"to_vec",[75,1123,1124],{"style":81},"())",[75,1126,401],{"style":85},[75,1128,111],{"style":81},[75,1130,1131,1134,1136,1138],{"class":77,"style":78},[75,1132,1133],{"style":92},"        Response",[75,1135,130],{"style":85},[75,1137,1016],{"style":92},[75,1139,1140],{"style":81},"(body)",[75,1142,1143],{"class":77,"style":78},[75,1144,301],{"style":81},[75,1146,1147],{"class":77,"style":78},[75,1148,242],{"style":81},[56,1150,31],{"id":30},[44,1152,1153,1155],{},[47,1154,21],{}," builds namespaced keys so services don't collide:",[59,1157,1158],{"language":69,"class":70},[47,1159,1160,97,1179],{"class":73},[75,1161,1162,1164,1166,1168,1170,1173,1176],{"class":77,"style":78},[75,1163,370],{"style":81},[75,1165,367],{"style":85},[75,1167,914],{"style":92},[75,1169,318],{"style":81},[75,1171,1172],{"style":394},"\"users:1\"",[75,1174,1175],{"style":81},");       ",[75,1177,1178],{"style":1057},"\u002F\u002F e.g. \"ferrite:users:1\"",[75,1180,1181,1183,1185,1187,1189,1191,1194],{"class":77,"style":78},[75,1182,370],{"style":81},[75,1184,367],{"style":85},[75,1186,914],{"style":92},[75,1188,318],{"style":81},[75,1190,321],{"style":85},[75,1192,1193],{"style":81},"request_key);    ",[75,1195,1196],{"style":1057},"\u002F\u002F helper for request-scoped keys",[56,1198,34],{"id":33},[1200,1201,1202,1206],"ul",{},[1203,1204,1205],"li",{},"All methods are async — they run on the Tokio runtime with the configured Redis connection.",[1203,1207,1208,1209,1212,1213,1215],{},"Use ",[47,1210,1211],{},"fr test --coverage"," + ",[47,1214,651],{}," for quick serialization smoke tests of your cache types.",[56,1217,37],{"id":36},[1200,1219,1220,1227],{},[1203,1221,1222,367],{},[1223,1224,1226],"a",{"href":1225},"\u002Fdocs\u002Ftechniques\u002Frate-limiting","Rate limiting",[1203,1228,1229,367],{},[1223,1230,1232],{"href":1231},"\u002Fdocs\u002Foverview\u002Finterceptors","Interceptors",{"title":12,"searchDepth":13,"depth":14,"links":1234},[1235,1236,1239,1240,1241,1242],{"id":17,"depth":13,"text":18},{"id":20,"depth":13,"text":21,"children":1237},[1238],{"id":24,"depth":14,"text":25},{"id":27,"depth":13,"text":28},{"id":30,"depth":13,"text":31},{"id":33,"depth":13,"text":34},{"id":36,"depth":13,"text":37},"https:\u002F\u002Fgithub.com\u002Fj4flmao\u002Fferrite_rs\u002Fedit\u002Fmain\u002Fdocs\u002Fcontent\u002Ftechniques\u002Fcaching.md",{"title":1245,"slug":1246},"OAuth2 & OIDC","techniques\u002Foauth2-oidc",{"title":1226,"slug":1248},"techniques\u002Frate-limiting",1789565440177]