go__cache/storage/interface.go

44 lines
1.1 KiB
Go

/*
The storage package contains the storage engines data types at its root, and the
actual engines in its subpackages.
*/
package storage
import "code.osinet.fr/fgm/gache/protocol"
// Flag is normally used as a bit mask.
type Flag uint64;
/*
Key is defined to ease switching from strings to more complex types at a later
time should the need arise, whilst keeping the interfaces.
*/
type Key string;
/*
Timestamp is a UNIX UTC timestamp. This type is only exposed
because it is used in the Memcached protocol, so passing it directly avoid
computations.
It may be negative, as the protocol needs this to mark an immediate expiration.
Any date/time handling beyond passing/returning protocol units should still use
time.Time values, not these timestamps.
See https://golang.org/pkg/time/#Unix
*/
type Timestamp int64;
type GetResult struct {
Key Key
Length uint64
Flags Flag
}
type GetResults []GetResult
type Storage interface {
Get([]Key) (GetResults, error)
Set(key Key, flags Flag, expire Timestamp, value []byte) error
Delete(key Key) (protocol.Result, error)
FlushAll(delay ...Timestamp) error
Quit()
}