@@ -16,16 +16,17 @@ Designed for persistently caching API requests in an unreliable environment, thi
1616
1717- ** Faster than a bat out of hell** - Best-in-class latency and throughput
1818- ** S3-FIFO eviction** - Better hit-rates than LRU ([ learn more] ( https://s3fifo.com/ ) )
19- - ** L2 Persistence (optional)** - Bring your own database or use built-in backends:
20- - [ ` pkg/persist/localfs ` ] ( pkg/persist/localfs ) - Local files (gob encoding, zero dependencies)
21- - [ ` pkg/persist/datastore ` ] ( pkg/persist/datastore ) - Google Cloud Datastore
22- - [ ` pkg/persist/valkey ` ] ( pkg/persist/valkey ) - Valkey/Redis
23- - [ ` pkg/persist/cloudrun ` ] ( pkg/persist/cloudrun ) - Auto-detect Cloud Run
19+ - ** Multi-tier persistent cache (optional)** - Bring your own database or use built-in backends:
20+ - [ ` pkg/store/cloudrun ` ] ( pkg/store/cloudrun ) - Automatically select Google Cloud Datastore in Cloud Run, localfs elsewhere
21+ - [ ` pkg/store/datastore ` ] ( pkg/store/datastore ) - Google Cloud Datastore
22+ - [ ` pkg/store/localfs ` ] ( pkg/store/localfs ) - Local files (gob encoding, zero dependencies)
23+ - [ ` pkg/store/null ` ] ( pkg/store/null ) - No-op (for testing or TieredCache API compatibility)
24+ - [ ` pkg/store/valkey ` ] ( pkg/store/valkey ) - Valkey/Redis
2425- ** Per-item TTL** - Optional expiration
2526- ** Thundering herd prevention** - ` GetSet ` deduplicates concurrent loads for the same key
2627- ** Graceful degradation** - Cache works even if persistence fails
2728- ** Zero allocation updates** - minimal GC thrashing
28- -
29+
2930## Usage
3031
3132As a stupid-fast in-memory cache:
@@ -44,7 +45,7 @@ Or as a multi-tier cache with local persistence to survive restarts:
4445``` go
4546import (
4647 " github.com/codeGROOVE-dev/sfcache"
47- " github.com/codeGROOVE-dev/sfcache/pkg/persist /localfs"
48+ " github.com/codeGROOVE-dev/sfcache/pkg/store /localfs"
4849)
4950
5051p , _ := localfs.New [string , User ](" myapp" , " " )
@@ -57,7 +58,7 @@ cache.Store.Len(ctx) // Access persistence layer directly
5758How about a persistent cache suitable for Cloud Run or local development? This uses Cloud DataStore if available, local files if not:
5859
5960``` go
60- import " github.com/codeGROOVE-dev/sfcache/pkg/persist /cloudrun"
61+ import " github.com/codeGROOVE-dev/sfcache/pkg/store /cloudrun"
6162
6263p , _ := cloudrun.New [string , User ](ctx, " myapp" )
6364cache , _ := sfcache.NewTiered (p)
@@ -163,7 +164,7 @@ Want even more comprehensive benchmarks? See https://github.com/tstromberg/gocac
163164
164165sfcache implements the core S3-FIFO algorithm (Small/Main/Ghost queues with frequency-based promotion) with these optimizations:
165166
166- 1 . ** Dynamic Sharding** - 1-256 independent S3-FIFO shards (vs single-threaded) for concurrent workloads
167+ 1 . ** Dynamic Sharding** - 1-2048 independent S3-FIFO shards (vs single-threaded) for concurrent workloads
1671682 . ** Bloom Filter Ghosts** - Two rotating Bloom filters track evicted keys (vs storing actual keys), reducing memory 10-100x
1681693 . ** Lazy Ghost Checks** - Only check ghosts when evicting, saving 5-9% latency when cache isn't full
1691704 . ** Intrusive Lists** - Embed pointers in entries (vs separate nodes) for zero-allocation queue ops
0 commit comments