interface.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. The storage package contains the storage engines data types at its root, and the
  3. actual engines in its subpackages.
  4. */
  5. package storage
  6. import "code.osinet.fr/fgm/gache/protocol"
  7. // Flag is normally used as a bit mask.
  8. type Flag uint64;
  9. /*
  10. Key is defined to ease switching from strings to more complex types at a later
  11. time should the need arise, whilst keeping the interfaces.
  12. */
  13. type Key string;
  14. /*
  15. Timestamp is a UNIX UTC timestamp. This type is only exposed
  16. because it is used in the Memcached protocol, so passing it directly avoid
  17. computations.
  18. It may be negative, as the protocol needs this to mark an immediate expiration.
  19. Any date/time handling beyond passing/returning protocol units should still use
  20. time.Time values, not these timestamps.
  21. See https://golang.org/pkg/time/#Unix
  22. */
  23. type Timestamp int64;
  24. type GetResult struct {
  25. Key Key
  26. Length uint64
  27. Flags Flag
  28. }
  29. type GetResults []GetResult
  30. type Storage interface {
  31. Get([]Key) (GetResults, error)
  32. Set(key Key, flags Flag, expire Timestamp, value []byte) error
  33. Delete(key Key) (protocol.Result, error)
  34. FlushAll(delay ...Timestamp) error
  35. Quit()
  36. }