mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-19 04:50:02 +02:00
rename app folder to internal.
This commit is contained in:
parent
afb90af1db
commit
9974bfe3fd
28 changed files with 23 additions and 23 deletions
31
internal/cache/cache.go
vendored
Normal file
31
internal/cache/cache.go
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package cache
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Cache struct {
|
||||
store Store
|
||||
prefix string
|
||||
}
|
||||
|
||||
// Create a new cache
|
||||
func NewCache(prefix string, store Store) *Cache {
|
||||
return &Cache{
|
||||
store: store,
|
||||
prefix: prefix,
|
||||
}
|
||||
}
|
||||
|
||||
func (cache *Cache) Get(ctx context.Context, key string, value any) error {
|
||||
return cache.store.Get(ctx, cache.key(key), value)
|
||||
}
|
||||
|
||||
func (cache *Cache) Set(ctx context.Context, key string, value any, ttl time.Duration) error {
|
||||
return cache.store.Set(ctx, cache.key(key), value, ttl)
|
||||
}
|
||||
|
||||
func (cache *Cache) key(key string) string {
|
||||
return cache.prefix + "::" + key
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue