mirror of
https://github.com/grafana/grafana.git
synced 2024-11-30 20:54:22 -06:00
Correct table names of sql storage for remotecache
This commit is contained in:
parent
d1e48a07b2
commit
c5bc723a6e
@ -101,7 +101,7 @@ func (dc *databaseCache) Set(key string, value interface{}, expire time.Duration
|
|||||||
|
|
||||||
// insert or update depending on if item already exist
|
// insert or update depending on if item already exist
|
||||||
if has {
|
if has {
|
||||||
sql := `UPDATE cache_data SET data=?, created=?, expire=? WHERE cache_key='?'`
|
sql := `UPDATE cache_data SET data=?, created_at=?, expires=? WHERE cache_key=?`
|
||||||
_, err = session.Exec(sql, data, getTime().Unix(), expiresInSeconds, key)
|
_, err = session.Exec(sql, data, getTime().Unix(), expiresInSeconds, key)
|
||||||
} else {
|
} else {
|
||||||
sql := `INSERT INTO cache_data (cache_key,data,created_at,expires) VALUES(?,?,?,?)`
|
sql := `INSERT INTO cache_data (cache_key,data,created_at,expires) VALUES(?,?,?,?)`
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bmizerany/assert"
|
"github.com/bmizerany/assert"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/log"
|
"github.com/grafana/grafana/pkg/log"
|
||||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||||
)
|
)
|
||||||
@ -54,3 +53,20 @@ func TestDatabaseStorageGarbageCollection(t *testing.T) {
|
|||||||
_, err = db.Get("key5")
|
_, err = db.Get("key5")
|
||||||
assert.Equal(t, err, nil)
|
assert.Equal(t, err, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSecondSet(t *testing.T) {
|
||||||
|
var err error
|
||||||
|
sqlstore := sqlstore.InitTestDB(t)
|
||||||
|
|
||||||
|
db := &databaseCache{
|
||||||
|
SQLStore: sqlstore,
|
||||||
|
log: log.New("remotecache.database"),
|
||||||
|
}
|
||||||
|
|
||||||
|
obj := &CacheableStruct{String: "hey!"}
|
||||||
|
|
||||||
|
err = db.Set("killa-gorilla", obj, 0)
|
||||||
|
err = db.Set("killa-gorilla", obj, 0)
|
||||||
|
|
||||||
|
assert.Equal(t, err, nil)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user