storage

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package storage provides interface and default implementation of storage as map for objects.

Usage:

s := NewMapStorage()

obj := &BaseObject{}
key := s.Set(obj)

s.Get(key)
s.GetKey()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MapStorage

type MapStorage struct {
	// contains filtered or unexported fields
}

MapStorage is Storage interface implementation with map as place for store.

func NewMapStorage

func NewMapStorage() *MapStorage

NewMapStorage creates new MapStorage instance with empty storage.

func (*MapStorage) Get

func (m *MapStorage) Get(record string) (interface{}, error)

Get restore object from storage.

func (*MapStorage) GetKeys

func (m *MapStorage) GetKeys() []string

GetKeys gives list of all keys in storage.

func (*MapStorage) Set

func (m *MapStorage) Set(obj interface{}) (string, error)

Set store object into storage.

type Storage

type Storage interface {
	Set(obj interface{}) (string, error)
	Get(record string) (interface{}, error)
	GetKeys() []string
}

Storage allows to store any objects by unique string key.

Jump to

Keyboard shortcuts

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