Documentation ¶
Overview ¶
Package file contains an implementation of the `gokv.Store` interface for local files. Each key-value pair is a file with the key as name and the value as content.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultOptions = Options{ Directory: "gokv", FilenameExtension: &defaultFilenameExtension, Codec: encoding.JSON, }
DefaultOptions is an Options object with default values. Directory: "gokv", Codec: encoding.JSON
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct { // The directory in which to store files. // Can be absolute or relative. // Optional ("gokv" by default). Directory string // Extension of the filename, e.g. "json". // This makes it easier for example to open a file with a text editor that supports syntax highlighting. // But it can lead to redundant and/or stale data if you switch the Codec back and forth! // You also should make sure to change this when changing the Codec, // although it doesn't matter for gokv, but it might be confusing when there's a gob file with a ".json" filename extension. // Set to "" to disable. // Optional ("json" by default). FilenameExtension *string // Encoding format. // Note: When you change this, you should also change the FilenameExtension if it's not empty (""). // Optional (encoding.JSON by default). Codec encoding.Codec }
Options are the options for the Go map store.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a gokv.Store implementation for storing key-value pairs as files.
func NewStore ¶
NewStore creates a new Go map store.
You should call the Close() method on the store when you're done working with it.
func (Store) Close ¶
Close closes the store. When called, some resources of the store are left for garbage collection.
func (Store) Delete ¶
Delete deletes the stored value for the given key. Deleting a non-existing key-value pair does NOT lead to an error. The key must not be "".
func (Store) Get ¶
Get retrieves the stored value for the given key. You need to pass a pointer to the value, so in case of a struct the automatic unmarshalling can populate the fields of the object that v points to with the values of the retrieved object's values. If no value is found it returns (false, nil). The key must not be "" and the pointer must not be nil.