You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
463 B
20 lines
463 B
package data |
|
|
|
import ( |
|
"errors" |
|
) |
|
|
|
// GetCachedValue will return a value for key from the cache. |
|
func (ds *Datastore) GetCachedValue(key string) ([]byte, error) { |
|
// Check for a cached value |
|
if val, ok := ds.cache.Load(key); ok { |
|
return val.([]byte), nil |
|
} |
|
|
|
return nil, errors.New(key + " not found in cache") |
|
} |
|
|
|
// SetCachedValue will set a value for key in the cache. |
|
func (ds *Datastore) SetCachedValue(key string, b []byte) { |
|
ds.cache.Store(key, b) |
|
}
|
|
|