Skip to content

Commit 5eed99b

Browse files
committed
update deps
1 parent 6b6140b commit 5eed99b

5 files changed

Lines changed: 47 additions & 44 deletions

File tree

go.mod

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@ module github.com/codeGROOVE-dev/prcost
33
go 1.25.4
44

55
require (
6-
github.com/codeGROOVE-dev/bdcache v0.6.1
7-
github.com/codeGROOVE-dev/bdcache/persist/cloudrun v0.0.0-20251121210535-3893c2b92813
86
github.com/codeGROOVE-dev/gsm v0.0.0-20251019065141-833fe2363d22
97
github.com/codeGROOVE-dev/prx v0.0.0-20251109164430-90488144076d
8+
github.com/codeGROOVE-dev/sfcache v1.0.0
9+
github.com/codeGROOVE-dev/sfcache/pkg/persist/cloudrun v0.0.0-20251204213114-4bd746588935
1010
github.com/codeGROOVE-dev/turnclient v0.0.0-20251107215141-ee43672b3dc7
1111
golang.org/x/time v0.14.0
1212
)
1313

1414
require (
15-
github.com/codeGROOVE-dev/bdcache/persist/datastore v0.0.0 // indirect
16-
github.com/codeGROOVE-dev/bdcache/persist/localfs v0.0.0 // indirect
1715
github.com/codeGROOVE-dev/ds9 v0.7.1 // indirect
1816
github.com/codeGROOVE-dev/retry v1.3.0 // indirect
17+
github.com/codeGROOVE-dev/sfcache/pkg/persist v0.0.0 // indirect
18+
github.com/codeGROOVE-dev/sfcache/pkg/persist/datastore v0.0.0 // indirect
19+
github.com/codeGROOVE-dev/sfcache/pkg/persist/localfs v0.0.0 // indirect
1920
)
2021

2122
replace (
22-
github.com/codeGROOVE-dev/bdcache/persist/datastore => github.com/codeGROOVE-dev/bdcache/persist/datastore v0.0.0-20251121210535-3893c2b92813
23-
github.com/codeGROOVE-dev/bdcache/persist/localfs => github.com/codeGROOVE-dev/bdcache/persist/localfs v0.0.0-20251121210535-3893c2b92813
23+
github.com/codeGROOVE-dev/sfcache/pkg/persist => github.com/codeGROOVE-dev/sfcache/pkg/persist v0.0.0-20251204213114-4bd746588935
24+
github.com/codeGROOVE-dev/sfcache/pkg/persist/datastore => github.com/codeGROOVE-dev/sfcache/pkg/persist/datastore v0.0.0-20251204213114-4bd746588935
25+
github.com/codeGROOVE-dev/sfcache/pkg/persist/localfs => github.com/codeGROOVE-dev/sfcache/pkg/persist/localfs v0.0.0-20251204213114-4bd746588935
2426
)

go.sum

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
github.com/codeGROOVE-dev/bdcache v0.6.1 h1:iFvZTXG+tYcfGHD2Jt4Ud/x7/34O/6kTYP9L6XFQ4QQ=
2-
github.com/codeGROOVE-dev/bdcache v0.6.1/go.mod h1:wJEFNbumCspw3PoiW17afq7QaMSeWXtMDO8WOH3GY74=
3-
github.com/codeGROOVE-dev/bdcache/persist/cloudrun v0.0.0-20251121210535-3893c2b92813 h1:YSXxW9+Xa8aN0TqX/wGUOfJzdezcdmmznX5y3CT2ZoM=
4-
github.com/codeGROOVE-dev/bdcache/persist/cloudrun v0.0.0-20251121210535-3893c2b92813/go.mod h1:cZfKOT5VU9soDvnNPGjp1Rp8C6E6+ZGfrxqIim05d/U=
5-
github.com/codeGROOVE-dev/bdcache/persist/datastore v0.0.0-20251121210535-3893c2b92813 h1:4wcq59rACcRBgbQJGYC2N4Redg4LqmPiM4HkJ3ssXi0=
6-
github.com/codeGROOVE-dev/bdcache/persist/datastore v0.0.0-20251121210535-3893c2b92813/go.mod h1:Q9Bww3n+lMC/kmFdEhslCEyu0l4bsJym0CoH/W1VAVA=
7-
github.com/codeGROOVE-dev/bdcache/persist/localfs v0.0.0-20251121210535-3893c2b92813 h1:sjXDZCJllfGRAE3yGhI1Ns8/w1S72/RCqoJ0K/qeFHU=
8-
github.com/codeGROOVE-dev/bdcache/persist/localfs v0.0.0-20251121210535-3893c2b92813/go.mod h1:I6U3M/72lAouQCf9EoWPJPDop8gPbDlMl9CgWKjxREg=
91
github.com/codeGROOVE-dev/ds9 v0.7.1 h1:UuffbTksanUPERBkOsiPOe46fkTJlzBOA9jUyfkBxEI=
102
github.com/codeGROOVE-dev/ds9 v0.7.1/go.mod h1:0UDipxF1DADfqM5GtjefgB2u+EXdDgOKmxVvrSGLHoM=
113
github.com/codeGROOVE-dev/gsm v0.0.0-20251019065141-833fe2363d22 h1:gtN3rOc6YspO646BkcOxBhPjEqKUz+jl175jIqglfDg=
@@ -14,6 +6,18 @@ github.com/codeGROOVE-dev/prx v0.0.0-20251109164430-90488144076d h1:KKt93PVYR9Ug
146
github.com/codeGROOVE-dev/prx v0.0.0-20251109164430-90488144076d/go.mod h1:FEy3gz9IYDXWnKWkoDSL+pWu6rujxbBSrF4w5A8QSK0=
157
github.com/codeGROOVE-dev/retry v1.3.0 h1:/+ipAWRJLL6y1R1vprYo0FSjSBvH6fE5j9LKXjpD54g=
168
github.com/codeGROOVE-dev/retry v1.3.0/go.mod h1:8OgefgV1XP7lzX2PdKlCXILsYKuz6b4ZpHa/20iLi8E=
9+
github.com/codeGROOVE-dev/sfcache v0.9.9 h1:iPDT+mGFgAmwHumsHi3N2QPFiym1a/8SGDqQWle2uYQ=
10+
github.com/codeGROOVE-dev/sfcache v0.9.9/go.mod h1:ksV5Y1RwKmOPZZiV0zXpsBOENGUCgO0fVgr/P8f/DJM=
11+
github.com/codeGROOVE-dev/sfcache v1.0.0 h1:V9uIpH4L+uzHhBDoh8Omv53e+A9zqBqwOWfhQIsiw5s=
12+
github.com/codeGROOVE-dev/sfcache v1.0.0/go.mod h1:E6OGpSFj896M3HfKHFiOefqeZia5NQDGQcNYO295QY8=
13+
github.com/codeGROOVE-dev/sfcache/pkg/persist v0.0.0-20251204213114-4bd746588935 h1:AZnIfyTQ1BQ1BeuG5/e7JlZ5jhvxO+mH1M1vIcBK624=
14+
github.com/codeGROOVE-dev/sfcache/pkg/persist v0.0.0-20251204213114-4bd746588935/go.mod h1:5D7qOtzUK/FgzBCjdaQa7r5i/sizbZH/grEcq+kGntY=
15+
github.com/codeGROOVE-dev/sfcache/pkg/persist/cloudrun v0.0.0-20251204213114-4bd746588935 h1:ag6QG5MgAGMcRLLqnSwlaYnd/TXdOycxaMHXoojTmog=
16+
github.com/codeGROOVE-dev/sfcache/pkg/persist/cloudrun v0.0.0-20251204213114-4bd746588935/go.mod h1:Dv9mdVxOYYWtjTTthw2AogXa+oNlfJRpL8rBuMroOdA=
17+
github.com/codeGROOVE-dev/sfcache/pkg/persist/datastore v0.0.0-20251204213114-4bd746588935 h1:PxGR7GpnRPraPWVs7l2D18o8pT3kCBzAqrPk7vid04Q=
18+
github.com/codeGROOVE-dev/sfcache/pkg/persist/datastore v0.0.0-20251204213114-4bd746588935/go.mod h1:IGJX3Be//ljTYtvAgVOkbQDiPREHZYrE4egq5hgmhzM=
19+
github.com/codeGROOVE-dev/sfcache/pkg/persist/localfs v0.0.0-20251204213114-4bd746588935 h1:l4wUVFc940kKXCcDShEEpjiE9lxzYkk1d5TFeBMtlsY=
20+
github.com/codeGROOVE-dev/sfcache/pkg/persist/localfs v0.0.0-20251204213114-4bd746588935/go.mod h1:t7o0BOEaBLW4Ys+f5H3dJ+QkmhryGXorWN8kDkLz5AI=
1721
github.com/codeGROOVE-dev/turnclient v0.0.0-20251107215141-ee43672b3dc7 h1:183q0bj2y/9hh/K0HZvDXI6sG7liYSRcQVgFx0GY+UA=
1822
github.com/codeGROOVE-dev/turnclient v0.0.0-20251107215141-ee43672b3dc7/go.mod h1:dVS3MlJDgL6WkfurJAyS7I9Fe1yxxoxxarjVifY5bIo=
1923
golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=

internal/server/server.go

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
"sync"
2121
"time"
2222

23-
"github.com/codeGROOVE-dev/bdcache"
24-
"github.com/codeGROOVE-dev/bdcache/persist/cloudrun"
23+
"github.com/codeGROOVE-dev/sfcache"
24+
"github.com/codeGROOVE-dev/sfcache/pkg/persist/cloudrun"
2525
"github.com/codeGROOVE-dev/gsm"
2626
"github.com/codeGROOVE-dev/prcost/pkg/cost"
2727
"github.com/codeGROOVE-dev/prcost/pkg/github"
@@ -78,10 +78,10 @@ type Server struct {
7878
allowAllCors bool
7979
validateTokens bool
8080
r2rCallout bool
81-
// Caching using bdcache (memory + optional persistence).
82-
githubCache *bdcache.Cache[string, any] // Unified 72h cache for all GitHub queries
83-
prDataCache *bdcache.Cache[string, cost.PRData] // 6-day cache for PR detail data
84-
calcResultCache *bdcache.Cache[string, cost.Breakdown] // 6-day cache for calculation results
81+
// Caching using sfcache (memory + optional persistence).
82+
githubCache *sfcache.PersistentCache[string, any] // Unified 72h cache for all GitHub queries
83+
prDataCache *sfcache.PersistentCache[string, cost.PRData] // 6-day cache for PR detail data
84+
calcResultCache *sfcache.PersistentCache[string, cost.Breakdown] // 6-day cache for calculation results
8585
githubClient *github.Client // Cached GitHub API client
8686
}
8787

@@ -179,18 +179,17 @@ func New() *Server {
179179
dbName = "prcost"
180180
}
181181

182-
// Initialize caches with bdcache (automatically handles memory + persistence).
182+
// Initialize caches with sfcache (automatically handles memory + persistence).
183183
// cloudrun.New uses Cloud Datastore when K_SERVICE is set (Cloud Run/Knative), local files otherwise.
184184
// Single unified cache with 72-hour TTL for all GitHub query results.
185185
githubPersist, err := cloudrun.New[string, any](ctx, dbName)
186186
if err != nil {
187187
logger.ErrorContext(ctx, "Failed to initialize GitHub cache persistence", "error", err)
188188
return nil
189189
}
190-
githubCache, err := bdcache.New[string, any](ctx,
191-
bdcache.WithPersistence(githubPersist),
192-
bdcache.WithDefaultTTL(72*time.Hour),
193-
bdcache.WithMemorySize(2000),
190+
githubCache, err := sfcache.Persistent[string, any](ctx, githubPersist,
191+
sfcache.WithTTL(72*time.Hour),
192+
sfcache.WithSize(2000),
194193
)
195194
if err != nil {
196195
logger.ErrorContext(ctx, "Failed to initialize GitHub cache", "error", err)
@@ -203,10 +202,9 @@ func New() *Server {
203202
logger.ErrorContext(ctx, "Failed to initialize PR data cache persistence", "error", err)
204203
return nil
205204
}
206-
prDataCache, err := bdcache.New[string, cost.PRData](ctx,
207-
bdcache.WithPersistence(prDataPersist),
208-
bdcache.WithDefaultTTL(6*24*time.Hour),
209-
bdcache.WithMemorySize(1000),
205+
prDataCache, err := sfcache.Persistent[string, cost.PRData](ctx, prDataPersist,
206+
sfcache.WithTTL(6*24*time.Hour),
207+
sfcache.WithSize(1000),
210208
)
211209
if err != nil {
212210
logger.ErrorContext(ctx, "Failed to initialize PR data cache", "error", err)
@@ -218,10 +216,9 @@ func New() *Server {
218216
logger.ErrorContext(ctx, "Failed to initialize calc result cache persistence", "error", err)
219217
return nil
220218
}
221-
calcResultCache, err := bdcache.New[string, cost.Breakdown](ctx,
222-
bdcache.WithPersistence(calcResultPersist),
223-
bdcache.WithDefaultTTL(6*24*time.Hour),
224-
bdcache.WithMemorySize(1000),
219+
calcResultCache, err := sfcache.Persistent[string, cost.Breakdown](ctx, calcResultPersist,
220+
sfcache.WithTTL(6*24*time.Hour),
221+
sfcache.WithSize(1000),
225222
)
226223
if err != nil {
227224
logger.ErrorContext(ctx, "Failed to initialize calc result cache", "error", err)
@@ -360,9 +357,9 @@ func (s *Server) limiter(ctx context.Context, ip string) *rate.Limiter {
360357
return limiter
361358
}
362359

363-
// simpleCache implements github.Cache interface using a single bdcache[string, any].
360+
// simpleCache implements github.Cache interface using a single sfcache[string, any].
364361
type simpleCache struct {
365-
cache *bdcache.Cache[string, any]
362+
cache *sfcache.PersistentCache[string, any]
366363
logger *slog.Logger
367364
}
368365

@@ -386,7 +383,7 @@ func (s *simpleCache) Set(ctx context.Context, key string, value any) {
386383
}
387384
}
388385

389-
// cachedPRData retrieves cached PR data using bdcache.
386+
// cachedPRData retrieves cached PR data using sfcache.
390387
func (s *Server) cachedPRData(ctx context.Context, key string) (cost.PRData, bool) {
391388
key = sanitizeCacheKey(key)
392389
prData, found, err := s.prDataCache.Get(ctx, key)
@@ -400,7 +397,7 @@ func (s *Server) cachedPRData(ctx context.Context, key string) (cost.PRData, boo
400397
return prData, found
401398
}
402399

403-
// cachePRData stores PR data using bdcache.
400+
// cachePRData stores PR data using sfcache.
404401
func (s *Server) cachePRData(ctx context.Context, key string, prData cost.PRData) {
405402
key = sanitizeCacheKey(key)
406403
// Uses the default TTL configured during initialization (6 days)
@@ -409,8 +406,8 @@ func (s *Server) cachePRData(ctx context.Context, key string, prData cost.PRData
409406
}
410407
}
411408

412-
// sanitizeCacheKey replaces characters not allowed by bdcache persistence layer.
413-
// bdcache only allows: alphanumeric, dash, underscore, period, colon.
409+
// sanitizeCacheKey replaces characters not allowed by sfcache persistence layer.
410+
// sfcache only allows: alphanumeric, dash, underscore, period, colon.
414411
// We replace: / with _ and = with -.
415412
func sanitizeCacheKey(key string) string {
416413
key = strings.ReplaceAll(key, "/", "_")
@@ -432,7 +429,7 @@ func configHash(cfg cost.Config) string {
432429
cfg.DeliveryDelayFactor)
433430
}
434431

435-
// cachedCalcResult retrieves cached calculation result using bdcache.
432+
// cachedCalcResult retrieves cached calculation result using sfcache.
436433
func (s *Server) cachedCalcResult(ctx context.Context, prURL string, cfg cost.Config) (cost.Breakdown, bool) {
437434
key := sanitizeCacheKey(fmt.Sprintf("calc:%s:%s", prURL, configHash(cfg)))
438435
breakdown, found, err := s.calcResultCache.Get(ctx, key)
@@ -443,7 +440,7 @@ func (s *Server) cachedCalcResult(ctx context.Context, prURL string, cfg cost.Co
443440
return breakdown, found
444441
}
445442

446-
// cacheCalcResult stores calculation result using bdcache.
443+
// cacheCalcResult stores calculation result using sfcache.
447444
func (s *Server) cacheCalcResult(ctx context.Context, prURL string, cfg cost.Config, b *cost.Breakdown) {
448445
key := sanitizeCacheKey(fmt.Sprintf("calc:%s:%s", prURL, configHash(cfg)))
449446
// Uses the default TTL configured during initialization (6 days)
@@ -469,7 +466,7 @@ func (s *Server) SetTokenValidation(appID string, keyFile string) error {
469466
// Shutdown gracefully shuts down the server.
470467
func (s *Server) Shutdown() {
471468
ctx := context.Background()
472-
// Close bdcache instances to flush any pending writes.
469+
// Close sfcache instances to flush any pending writes.
473470
if s.githubCache != nil {
474471
if err := s.githubCache.Close(); err != nil {
475472
s.logger.WarnContext(ctx, "Failed to close GitHub cache", "error", err)

internal/server/server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2455,7 +2455,7 @@ func TestCachedPRDataMissCache(t *testing.T) {
24552455
}
24562456

24572457
// TestCachedPRQueryBadType and TestCachedPRDataBadType removed:
2458-
// bdcache uses generic types, so type mismatches are impossible at compile time.
2458+
// sfcache uses generic types, so type mismatches are impossible at compile time.
24592459

24602460
func TestLimiterCleanupLarge(t *testing.T) {
24612461
s := New()

pkg/github/query.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
)
1717

1818
// Cache is a simple interface for caching any type of data.
19-
// The server provides this via bdcache, with proper TTLs for each data type.
19+
// The server provides this via sfcache, with proper TTLs for each data type.
2020
type Cache interface {
2121
Get(ctx context.Context, key string) (any, bool)
2222
Set(ctx context.Context, key string, value any)

0 commit comments

Comments
 (0)