Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
6d42d43b
Commit
6d42d43b
authored
Mar 14, 2019
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use constants for cache type
parent
0a86a1d7
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
5 deletions
+11
-5
pkg/infra/remotecache/database_storage.go
+2
-0
pkg/infra/remotecache/memcached_storage.go
+2
-0
pkg/infra/remotecache/memcached_storage_integration_test.go
+1
-1
pkg/infra/remotecache/redis_storage.go
+2
-0
pkg/infra/remotecache/redis_storage_integration_test.go
+1
-1
pkg/infra/remotecache/remotecache.go
+3
-3
No files found.
pkg/infra/remotecache/database_storage.go
View file @
6d42d43b
...
@@ -10,6 +10,8 @@ import (
...
@@ -10,6 +10,8 @@ import (
var
getTime
=
time
.
Now
var
getTime
=
time
.
Now
const
databaseCacheType
=
"database"
type
databaseCache
struct
{
type
databaseCache
struct
{
SQLStore
*
sqlstore
.
SqlStore
SQLStore
*
sqlstore
.
SqlStore
log
log
.
Logger
log
log
.
Logger
...
...
pkg/infra/remotecache/memcached_storage.go
View file @
6d42d43b
...
@@ -7,6 +7,8 @@ import (
...
@@ -7,6 +7,8 @@ import (
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/setting"
)
)
const
memcachedCacheType
=
"memcached"
type
memcachedStorage
struct
{
type
memcachedStorage
struct
{
c
*
memcache
.
Client
c
*
memcache
.
Client
}
}
...
...
pkg/infra/remotecache/memcached_storage_integration_test.go
View file @
6d42d43b
...
@@ -9,7 +9,7 @@ import (
...
@@ -9,7 +9,7 @@ import (
)
)
func
TestMemcachedCacheStorage
(
t
*
testing
.
T
)
{
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
)
client
:=
createTestClient
(
t
,
opts
,
nil
)
runTestsForClient
(
t
,
client
)
runTestsForClient
(
t
,
client
)
}
}
pkg/infra/remotecache/redis_storage.go
View file @
6d42d43b
...
@@ -7,6 +7,8 @@ import (
...
@@ -7,6 +7,8 @@ import (
redis
"gopkg.in/redis.v2"
redis
"gopkg.in/redis.v2"
)
)
const
redisCacheType
=
"redis"
type
redisStorage
struct
{
type
redisStorage
struct
{
c
*
redis
.
Client
c
*
redis
.
Client
}
}
...
...
pkg/infra/remotecache/redis_storage_integration_test.go
View file @
6d42d43b
...
@@ -10,7 +10,7 @@ import (
...
@@ -10,7 +10,7 @@ import (
func
TestRedisCacheStorage
(
t
*
testing
.
T
)
{
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
)
client
:=
createTestClient
(
t
,
opts
,
nil
)
runTestsForClient
(
t
,
client
)
runTestsForClient
(
t
,
client
)
}
}
pkg/infra/remotecache/remotecache.go
View file @
6d42d43b
...
@@ -92,15 +92,15 @@ func (ds *RemoteCache) Run(ctx context.Context) error {
...
@@ -92,15 +92,15 @@ func (ds *RemoteCache) Run(ctx context.Context) error {
}
}
func
createClient
(
opts
*
setting
.
RemoteCacheOptions
,
sqlstore
*
sqlstore
.
SqlStore
)
(
CacheStorage
,
error
)
{
func
createClient
(
opts
*
setting
.
RemoteCacheOptions
,
sqlstore
*
sqlstore
.
SqlStore
)
(
CacheStorage
,
error
)
{
if
opts
.
Name
==
"redis"
{
if
opts
.
Name
==
redisCacheType
{
return
newRedisStorage
(
opts
),
nil
return
newRedisStorage
(
opts
),
nil
}
}
if
opts
.
Name
==
"memcached"
{
if
opts
.
Name
==
memcachedCacheType
{
return
newMemcachedStorage
(
opts
),
nil
return
newMemcachedStorage
(
opts
),
nil
}
}
if
opts
.
Name
==
"database"
{
if
opts
.
Name
==
databaseCacheType
{
return
newDatabaseCache
(
sqlstore
),
nil
return
newDatabaseCache
(
sqlstore
),
nil
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment