Commit 6d42d43b by bergquist

use constants for cache type

parent 0a86a1d7
......@@ -10,6 +10,8 @@ import (
var getTime = time.Now
const databaseCacheType = "database"
type databaseCache struct {
SQLStore *sqlstore.SqlStore
log log.Logger
......
......@@ -7,6 +7,8 @@ import (
"github.com/grafana/grafana/pkg/setting"
)
const memcachedCacheType = "memcached"
type memcachedStorage struct {
c *memcache.Client
}
......
......@@ -9,7 +9,7 @@ import (
)
func TestMemcachedCacheStorage(t *testing.T) {
opts := &setting.RemoteCacheOptions{Name: "memcached", ConnStr: "localhost:11211"}
opts := &setting.RemoteCacheOptions{Name: memcachedCacheType, ConnStr: "localhost:11211"}
client := createTestClient(t, opts, nil)
runTestsForClient(t, client)
}
......@@ -7,6 +7,8 @@ import (
redis "gopkg.in/redis.v2"
)
const redisCacheType = "redis"
type redisStorage struct {
c *redis.Client
}
......
......@@ -10,7 +10,7 @@ import (
func TestRedisCacheStorage(t *testing.T) {
opts := &setting.RemoteCacheOptions{Name: "redis", ConnStr: "localhost:6379"}
opts := &setting.RemoteCacheOptions{Name: redisCacheType, ConnStr: "localhost:6379"}
client := createTestClient(t, opts, nil)
runTestsForClient(t, client)
}
......@@ -92,15 +92,15 @@ func (ds *RemoteCache) Run(ctx context.Context) error {
}
func createClient(opts *setting.RemoteCacheOptions, sqlstore *sqlstore.SqlStore) (CacheStorage, error) {
if opts.Name == "redis" {
if opts.Name == redisCacheType {
return newRedisStorage(opts), nil
}
if opts.Name == "memcached" {
if opts.Name == memcachedCacheType {
return newMemcachedStorage(opts), nil
}
if opts.Name == "database" {
if opts.Name == databaseCacheType {
return newDatabaseCache(sqlstore), nil
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment