Documentation ¶
Overview ¶
Package memory is an in memory storage backend for Shade.
It stores files and chunks transiently in RAM. It respects MaxFiles and MaxChukBytes as an LRU cache, evicting the least-recently-used file or chunk. Both Gets and Puts are considered "uses", but GetFiles does not update the LRU state of any data.
Index ¶
- func NewClient(c drive.Config) (drive.Client, error)
- type ChunkLister
- type Drive
- func (s *Drive) Equal(other *Drive) error
- func (s *Drive) GetChunk(sha256sum []byte, _ *shade.File) ([]byte, error)
- func (s *Drive) GetConfig() drive.Config
- func (s *Drive) GetFile(sha256sum []byte) ([]byte, error)
- func (s *Drive) ListFiles() ([][]byte, error)
- func (s *Drive) Local() bool
- func (s *Drive) NewChunkLister() drive.ChunkLister
- func (s *Drive) Persistent() bool
- func (s *Drive) PutChunk(sha256sum []byte, chunk []byte, _ *shade.File) error
- func (s *Drive) PutFile(sha256sum, f []byte) error
- func (s *Drive) ReleaseChunk(sha256sum []byte) error
- func (s *Drive) ReleaseFile(sha256sum []byte) error
- func (s *Drive) Warm(chunks [][]byte, f *shade.File)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ChunkLister ¶
type ChunkLister struct {
// contains filtered or unexported fields
}
ChunkLister allows iterating the chunks stored in memory.
func (*ChunkLister) Sha256 ¶
func (c *ChunkLister) Sha256() []byte
Sha256 returns the chunk pointed to by the pointer.
type Drive ¶
type Drive struct {
// contains filtered or unexported fields
}
Drive implements the drive.Client interface by storing Files and Chunks transiently in RAM. The provided config can be returned, but is otherwise ignored.
func (*Drive) ListFiles ¶
ListFiles retrieves all of the File objects known to the client. The return is a list of sha256sums of the file object. The keys may be passed to GetFile() to retrieve the corresponding shade.File.
func (*Drive) NewChunkLister ¶
func (s *Drive) NewChunkLister() drive.ChunkLister
NewChunkLister allows listing all the chunks in memory.
func (*Drive) Persistent ¶
Persistent returns whether the storage is persistent across task restarts.
func (*Drive) PutFile ¶
PutFile writes the metadata describing a new file. f should be marshalled JSON, and may be encrypted.
func (*Drive) ReleaseChunk ¶
ReleaseChunk removes a chunk from the memory client.
func (*Drive) ReleaseFile ¶
ReleaseFile removes a file from the memory client.