Documentation ¶
Index ¶
- Constants
- type Collection
- func (collection *Collection) All() chan interface{}
- func (collection *Collection) Clear()
- func (collection *Collection) Count() int64
- func (collection *Collection) Delete(key string) bool
- func (collection *Collection) Exists(key string) bool
- func (collection *Collection) Get(key string) (interface{}, error)
- func (collection *Collection) GetMany(keys []string) []interface{}
- func (collection *Collection) Set(key string, value interface{})
- type Configuration
- type Namespace
- func (ns *Namespace) All(name string) chan interface{}
- func (ns *Namespace) Clear(collection string)
- func (ns *Namespace) ClearAll()
- func (ns *Namespace) Close()
- func (ns *Namespace) Collection(name string) *Collection
- func (ns *Namespace) Delete(collection string, key string) bool
- func (ns *Namespace) Exists(collection string, key string) bool
- func (ns *Namespace) Get(collection string, key string) (interface{}, error)
- func (ns *Namespace) GetMany(collection string, keys []string) []interface{}
- func (ns *Namespace) HasType(typeName string) bool
- func (ns *Namespace) Node() *Node
- func (ns *Namespace) Prefetch()
- func (ns *Namespace) RegisterTypes(types ...interface{}) *Namespace
- func (ns *Namespace) Set(collection string, key string, value interface{})
- func (ns *Namespace) Types() map[string]reflect.Type
- type Node
- func (node *Node) Address() net.Addr
- func (node *Node) Broadcast(msg *packet.Packet)
- func (node *Node) Clear()
- func (node *Node) Client() *client.Node
- func (node *Node) Close()
- func (node *Node) IsClosed() bool
- func (node *Node) IsServer() bool
- func (node *Node) Namespace(name string) *Namespace
- func (node *Node) Server() *server.Node
Constants ¶
const ChannelBufferSize = 128
ChannelBufferSize is the size of the channels used to iterate over a whole collection.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection is a hash map of data of the same type that is synchronized across network and disk.
func (*Collection) All ¶
func (collection *Collection) All() chan interface{}
All returns a channel of all objects in the collection.
func (*Collection) Clear ¶
func (collection *Collection) Clear()
Clear deletes all objects from the collection.
func (*Collection) Count ¶ added in v0.1.8
func (collection *Collection) Count() int64
Count gives you a rough estimate of how many elements are in the collection. It DOES NOT GUARANTEE that the returned number is the actual number of elements. A good use for this function is to preallocate slices with the given capacity. In the future, this function could possibly return the exact number of elements.
func (*Collection) Delete ¶
func (collection *Collection) Delete(key string) bool
Delete deletes a key from the collection.
func (*Collection) Exists ¶
func (collection *Collection) Exists(key string) bool
Exists returns whether or not the key exists.
func (*Collection) Get ¶
func (collection *Collection) Get(key string) (interface{}, error)
Get returns the value for the given key.
func (*Collection) GetMany ¶
func (collection *Collection) GetMany(keys []string) []interface{}
GetMany is the same as Get, except it looks up multiple keys at once.
func (*Collection) Set ¶
func (collection *Collection) Set(key string, value interface{})
Set sets the value for the key.
type Configuration ¶ added in v0.3.0
type Configuration struct { // Port is the port used by the server and client nodes. Port int // Directory includes the path to the namespaces stored on the disk. Directory string // Hosts represents a list of node addresses that this node should connect to. Hosts []string }
Configuration represents the nano configuration which is only read once at node creation time.
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
Namespace combines multiple collections under a single name.
func (*Namespace) ClearAll ¶
func (ns *Namespace) ClearAll()
ClearAll deletes all objects from all collections, effectively resetting the entire database.
func (*Namespace) Close ¶
func (ns *Namespace) Close()
Close will close all collections in the namespace, forcing them to sync all data to disk before shutting down.
func (*Namespace) Collection ¶
func (ns *Namespace) Collection(name string) *Collection
Collection returns the collection with the given name.
func (*Namespace) Prefetch ¶
func (ns *Namespace) Prefetch()
Prefetch loads all the data for this namespace from disk into memory.
func (*Namespace) RegisterTypes ¶
RegisterTypes expects a list of pointers and will look up the types of the given pointers. These types will be registered so that collections can store data using the given type. Note that nil pointers are acceptable.