mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
removes memory as distcache option
if database caching is to expensive if should not use distcache in the first place.
This commit is contained in:
parent
b933b4efc8
commit
995647be2c
@ -40,10 +40,6 @@ func createClient(opts *setting.CacheOpts, sqlstore *sqlstore.SqlStore) cacheSto
|
||||
return newMemcacheStorage(opts)
|
||||
}
|
||||
|
||||
if opts.Name == "memory" {
|
||||
return newMemoryStorage()
|
||||
}
|
||||
|
||||
return newDatabaseCache(sqlstore)
|
||||
}
|
||||
|
||||
|
@ -1,35 +0,0 @@
|
||||
package distcache
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
gocache "github.com/patrickmn/go-cache"
|
||||
)
|
||||
|
||||
type memoryStorage struct {
|
||||
c *gocache.Cache
|
||||
}
|
||||
|
||||
func newMemoryStorage() *memoryStorage {
|
||||
return &memoryStorage{
|
||||
c: gocache.New(time.Minute*30, time.Minute*30),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *memoryStorage) Put(key string, val interface{}, expires time.Duration) error {
|
||||
return s.c.Add(key, val, expires)
|
||||
}
|
||||
|
||||
func (s *memoryStorage) Get(key string) (interface{}, error) {
|
||||
val, exist := s.c.Get(key)
|
||||
if !exist {
|
||||
return nil, ErrCacheItemNotFound
|
||||
}
|
||||
|
||||
return val, nil
|
||||
}
|
||||
|
||||
func (s *memoryStorage) Delete(key string) error {
|
||||
s.c.Delete(key)
|
||||
return nil
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package distcache
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
func TestMemoryCacheStorage(t *testing.T) {
|
||||
opts := &setting.CacheOpts{Name: "memory"}
|
||||
runTestsForClient(t, createTestClient(t, opts, nil))
|
||||
}
|
Loading…
Reference in New Issue
Block a user