Skip to content

Commit 87c858e

Browse files
committed
Moved get cache vals to here
1 parent 45f7cc5 commit 87c858e

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

datastore.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ import (
2222
)
2323

2424
type Datastore struct {
25-
Renderer *render.Render
26-
DB *runner.DB
27-
Cache *redis.Client
28-
Settings *Settings
25+
Renderer *render.Render
26+
DB *runner.DB
27+
Cache *redis.Client
28+
Settings *Settings
29+
Websocket Websocket
2930
}
3031

3132
// New - returns a new datastore which contains redis, database, view globals and settings.
@@ -274,3 +275,17 @@ func (s *Settings) Get(setting string) string {
274275
// s := s3.New(session.New(), cfg)
275276
// return s
276277
// }
278+
279+
type Websocket interface {
280+
Broadcast(string, string) error
281+
}
282+
283+
func (ds *Datastore) GetCacheValue(key string) (string, error) {
284+
val := ds.Cache.Get(key)
285+
return val.Result()
286+
}
287+
288+
func (ds *Datastore) SetCacheValue(key string, value interface{}, duration time.Duration) (string, error) {
289+
val := ds.Cache.Set(key, value, duration)
290+
return val.Result()
291+
}

0 commit comments

Comments
 (0)