yakvs

package
v0.0.0-...-8b3b547 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2018 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Server
	Logging
}

Config represents a set of configuration options for a YAKVS server.

type Logging

type Logging struct {
	Connection_accepted bool
	Connection_closed   bool
	Connection_refused  bool
	Invalid_command     bool
	Clear               bool
	Put                 bool
	Remove              bool
	Get                 bool
	Haskey              bool
	Hasvalue            bool
	List                bool
	List_keys           bool
	List_values         bool
	Size                bool
	Quit                bool
}

type Server

type Server struct {
	Port               int
	Max_clients        int
	Connection_timeout time.Duration
}

type YAKVS

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

YAKVS represents a networked, in-memory, key-value store.

func NewServer

func NewServer(cfg Config) *YAKVS

NewServer creates a new key-value store. config is the server configuration settings.

func (*YAKVS) Clear

func (s *YAKVS) Clear()

Clear removes all key-value mappings from this store.

func (*YAKVS) Get

func (s *YAKVS) Get(key string) (value string, has bool)

Get returns the value mapped to the specified key, or nil, as well as true if the mapping exists.

func (*YAKVS) HasKey

func (s *YAKVS) HasKey(key string) bool

HasKey returns true if the specified key has a mapping in this store.

func (*YAKVS) HasValue

func (s *YAKVS) HasValue(value string) bool

HasValue returns true if the specified value has a mapping in this store.

func (*YAKVS) List

func (s *YAKVS) List() (keys []string, values []string, size int)

List returns a slice containing all keys in this store, a slice containing all values in this store, and the size of the store.

func (*YAKVS) Put

func (s *YAKVS) Put(key, value string)

Put adds a mapping from the specified value to the specified key.

func (*YAKVS) Remove

func (s *YAKVS) Remove(key string)

Remove deletes a key-value mapping from this store. If the specified key does not have a mapping, nothing happens.

func (*YAKVS) Size

func (s *YAKVS) Size() int

Size returns the number of key-value mappings in this store.

func (*YAKVS) Start

func (s *YAKVS) Start() error

Start starts the network listener on the store. This method blocks while the server is running.

func (*YAKVS) Stop

func (s *YAKVS) Stop() error

Stop stops the server, closing all connections.

Jump to

Keyboard shortcuts

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