tidstore

package module
v0.0.0-...-bf3ff57 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2016 License: LGPL-3.0 Imports: 5 Imported by: 0

README

tidstore

TIDStore is a Go library that interfaces and implements identified stores.

Warning

TIDStore is still in development! The API is not frozen, so please don't use it in your personal projects yet if you are not ready to update your code eventually.

Documentation

Index

Constants

View Source
const DefaultMaxAge = 86400

DefaultMaxAge is a constant that can be used by stores for giving a storage a default max age. Is set to 86400 seconds (one day).

Variables

This section is empty.

Functions

This section is empty.

Types

type FilesystemStore

type FilesystemStore struct {
	BasePath string
}

FilesystemStore provides an implementation of the Store interface that writes the storages to the filesystem, relative to the BasePath

func NewFilesystemStore

func NewFilesystemStore() *FilesystemStore

NewFilesystemStore creates a new FilesystemStore with the OS' temporary directory as the BasePath

func (*FilesystemStore) Get

func (store *FilesystemStore) Get(key string) (*Storage, error)

Get implements the Get method of the Store interface.

func (*FilesystemStore) Save

func (store *FilesystemStore) Save(storage *Storage) error

Save implements the Save method of the Store interface.

type Options

type Options struct {
	Key      string
	MaxAge   int
	Creation time.Time
	InStore  bool
	IsNew    bool
}

Options stores the options and the metadata of a specific Storage

type Storage

type Storage struct {
	Values  map[interface{}]interface{}
	Options Options
}

Storage stores the underlying in-memory key-value map, and its options.

func NewStorage

func NewStorage(key string, maxAge int) *Storage

NewStorage creates a new storage, not in store, with the given key and max age.

type Store

type Store interface {
	// Get must create a Storage if it doesn't exists and return it.
	// Note that the Storage must never be nil, even if there is a error
	// creating or reading it. See the 'InStore' attribute in Storage.Options.
	Get(key string) (error, *Storage)

	// Save must save a Storage to the store. Must also set the
	// Storage.Options.IsNew boolean to false before saving it.
	Save(storage *Storage) error
}

Store provides an interface for implementating new stores

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL