Documentation ¶
Overview ¶
Package memstore contains a store which is just a collection of key-value entries with immutability capabilities.
Created after that proposal: https://github.com/iris-contrib/community-board/issues/5 and it's being used by session entries (session lifetime) and context's entries (per-request).
Developers can use that storage to their own apps if they like its behavior. It's fast and in the same time you get read-only access (safety) when you need it.
Index ¶
- Variables
- type Entry
- type Store
- func (r *Store) Get(key string) interface{}
- func (r *Store) GetInt(key string) (int, error)
- func (r *Store) GetInt64(key string) (int64, error)
- func (r *Store) GetString(key string) string
- func (r *Store) Len() int
- func (r *Store) Remove(key string) bool
- func (r *Store) Reset()
- func (r *Store) Set(key string, value interface{})
- func (r *Store) SetImmutable(key string, value interface{})
- func (r *Store) Visit(visitor func(key string, value interface{}))
Constants ¶
This section is empty.
Variables ¶
var ErrIntParse = errors.New("unable to find or parse the integer, found: %#v")
ErrIntParse returns an error message when int parse failed it's not statical error, it depends on the failed value.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct { Key string // contains filtered or unexported fields }
Entry is the entry of the context storage Store - .Values()
type Store ¶
type Store []Entry
Store is a collection of key-value entries with immutability capabilities.
func (*Store) Remove ¶
Remove deletes an entry linked to that "key", returns true if an entry is actually removed.
func (*Store) SetImmutable ¶
SetImmutable saves a value to the key-value storage. Unlike `Set`, the output value cannot be changed by the caller later on (when .Get OR .Set)
An Immutable entry should be only changed with a `SetImmutable`, simple `Set` will not work if the entry was immutable, for your own safety.
Use it consistently, it's far slower than `Set`. Read more about muttable and immutable go types: https://stackoverflow.com/a/8021081