2017-02-11 14:51:16 +00:00
package main
2017-09-03 04:50:31 +00:00
2017-02-11 14:51:16 +00:00
import "errors"
2017-09-03 04:50:31 +00:00
// Go away, linter. We need to differentiate constants from variables somehow ;)
// nolint
2017-02-11 14:51:16 +00:00
const CACHE_STATIC int = 0
const CACHE_DYNAMIC int = 1
const CACHE_SQL int = 2
2017-09-03 04:50:31 +00:00
// ErrCacheDesync is thrown whenever a piece of data, for instance, a user is out of sync with the database. Currently unused.
2017-09-10 16:57:22 +00:00
var ErrCacheDesync = errors . New ( "The cache is out of sync with the database." ) // TODO: A cross-server synchronisation mechanism
2017-09-03 04:50:31 +00:00
// ErrStoreCapacityOverflow is thrown whenever a datastore reaches it's maximum hard capacity. I'm not sure *if* this one is used, at the moment. Probably.
var ErrStoreCapacityOverflow = errors . New ( "This datastore has reached it's maximum capacity." )
2017-02-11 14:51:16 +00:00
2017-09-03 04:50:31 +00:00
// nolint
2017-02-11 14:51:16 +00:00
type DataStore interface {
2017-02-15 10:49:30 +00:00
Load ( id int ) error
2017-02-11 14:51:16 +00:00
Get ( id int ) ( interface { } , error )
GetUnsafe ( id int ) ( interface { } , error )
CascadeGet ( id int ) ( interface { } , error )
2017-06-06 14:41:06 +00:00
BypassGet ( id int ) ( interface { } , error )
2017-02-15 10:49:30 +00:00
Set ( item interface { } ) error
2017-02-11 14:51:16 +00:00
Add ( item interface { } ) error
AddUnsafe ( item interface { } ) error
Remove ( id int ) error
RemoveUnsafe ( id int ) error
GetLength ( ) int
GetCapacity ( ) int
}