mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00

- Pre-built prepared query statements - Remove DB mutex as it is not needed. - Add mutex around chat client send chan. - Replace maps in chat with sync.Maps and remove locks around them.
21 lines
463 B
Go
21 lines
463 B
Go
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)
|
|
}
|