github.com/Azareal/Gosora@v0.0.0-20210729070923-553e66b59003/common/cache.go (about) 1 package common 2 3 import "errors" 4 5 // nolint 6 // ErrCacheDesync is thrown whenever a piece of data, for instance, a user is out of sync with the database. Currently unused. 7 var ErrCacheDesync = errors.New("The cache is out of sync with the database.") // TODO: A cross-server synchronisation mechanism 8 9 // ErrStoreCapacityOverflow is thrown whenever a datastore reaches it's maximum hard capacity. I'm not sure if this error is actually used. It might be, we should check 10 var ErrStoreCapacityOverflow = errors.New("This datastore has reached it's maximum capacity.") // nolint 11 12 // nolint 13 type DataStore interface { 14 DirtyGet(id int) interface{} 15 Get(id int) (interface{}, error) 16 BypassGet(id int) (interface{}, error) 17 //Count() int 18 } 19 20 // nolint 21 type DataCache interface { 22 CacheGet(id int) (interface{}, error) 23 CacheGetUnsafe(id int) (interface{}, error) 24 CacheSet(item interface{}) error 25 CacheAdd(item interface{}) error 26 CacheAddUnsafe(item interface{}) error 27 CacheRemove(id int) error 28 CacheRemoveUnsafe(id int) error 29 Reload(id int) error 30 Flush() 31 Length() int 32 SetCapacity(capacity int) 33 GetCapacity() int 34 }