Documentation ¶
Overview ¶
Package store implements a simple flat file backed persistence mechanism for storing Spring '83 boards. This store should be suitable for both clients and servers. It aims for simplicity and portability over performance or features.
On disk a board is simply a plain text file named according to the publisher's key. The first line of the file is the signature. Everything else is the content.
The store package implements a write through cache that allows read-heavy use cases (like a server, where boards are read much more frequently then they are updated) to primarily operate out of memory.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func New ¶
New takes a path to a directory on disk and initializes the backing data structures. In loading the directory it validates any existing boards that are found. NewStore will error if the path provided is not a directory.
func (*Store) Add ¶
Add stores a board to disk. This will clobber any existing boards. This matches the ephemeral nature of the protocol. Any errors opening or writing the backing file will be returned.
func (*Store) Get ¶
Get retrieves a board from disk based on the key. On success it returns a valid board. Otherwise it returns an appropriate error, either based on the store (e.g. the board does not exist) or based on the contents of the file (e.g. it is an invalid board, the signature fails to verify, etc).