You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
Client Side Caching (#2947)
* CSC POC ontop of Parser * add csc file that weren't merged after patch * address review comments * nits to try and fix github * last change from review * Update client-side cache and improve documentation * Add client side caching RESP3 validation * Add documentation for RESP and unstableResp3 options * Add comprehensive cache statistics The `CacheStats` class provides detailed metrics like hit/miss counts, load success/failure counts, total load time, and eviction counts. It also offers derived metrics such as hit/miss rates, load failure rate, and average load penalty. The design is inspired by Caffeine. `BasicClientSideCache` now uses a `StatsCounter` to accumulate these statistics, exposed via a new `stats()` method. The previous `cacheHits()` and `cacheMisses()` methods have been removed. A `recordStats` option (default: true) in `ClientSideCacheConfig` allows disabling statistics collection. --------- Co-authored-by: Shaya Potter <shaya@redislabs.com>
This commit is contained in:
18
README.md
18
README.md
@@ -235,6 +235,24 @@ of sending a `QUIT` command to the server, the client can simply close the netwo
|
||||
client.destroy();
|
||||
```
|
||||
|
||||
### Client Side Caching
|
||||
|
||||
Node Redis v5 adds support for [Client Side Caching](https://redis.io/docs/manual/client-side-caching/), which enables clients to cache query results locally. The Redis server will notify the client when cached results are no longer valid.
|
||||
|
||||
```typescript
|
||||
// Enable client side caching with RESP3
|
||||
const client = createClient({
|
||||
RESP: 3,
|
||||
clientSideCache: {
|
||||
ttl: 0, // Time-to-live (0 = no expiration)
|
||||
maxEntries: 0, // Maximum entries (0 = unlimited)
|
||||
evictPolicy: "LRU" // Eviction policy: "LRU" or "FIFO"
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
See the [V5 documentation](./docs/v5.md#client-side-caching) for more details and advanced usage.
|
||||
|
||||
### Auto-Pipelining
|
||||
|
||||
Node Redis will automatically pipeline requests that are made during the same "tick".
|
||||
|
Reference in New Issue
Block a user