Skip to content

Commit f71b72d

Browse files
committed
[cache] add app-wide prefix
1 parent 7448bb2 commit f71b72d

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

internal/sms-gateway/cache/factory.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import (
88
"github.com/android-sms-gateway/server/pkg/cache"
99
)
1010

11+
const (
12+
keyPrefix = "sms-gateway:"
13+
)
14+
1115
type Cache = cache.Cache
1216

1317
type Factory interface {
@@ -52,5 +56,5 @@ func NewFactory(config Config) (Factory, error) {
5256

5357
// New implements Factory.
5458
func (f *factory) New(name string) (cache.Cache, error) {
55-
return f.new(name)
59+
return f.new(keyPrefix + name)
5660
}

pkg/cache/memory_edge_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func TestMemoryCache_RapidOperations(t *testing.T) {
241241
} else {
242242
key := "rapid-key-" + strconv.Itoa(i-1)
243243
_, err := c.Get(ctx, key)
244-
if err != nil && err != cache.ErrKeyNotFound {
244+
if err != nil {
245245
t.Errorf("Get failed: %v", err)
246246
}
247247
}

pkg/cache/memory_profile_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,10 @@ func TestMemoryCache_GCStress(t *testing.T) {
189189
runtime.GC()
190190

191191
// Verify cache operations still work
192-
for j := 0; j < 100; j++ {
192+
for j := range 100 {
193193
key := "gc-key-" + strconv.Itoa(j)
194194
_, err := c.Get(ctx, key)
195-
if err != nil && err != cache.ErrKeyNotFound {
195+
if err != nil {
196196
t.Errorf("Get failed during GC stress test: %v", err)
197197
}
198198
}

0 commit comments

Comments
 (0)