zero

package module
v0.0.0-...-2300a6e Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2016 License: MIT Imports: 5 Imported by: 0

README

zero Build Status Go Report Card

super tiny in-memory experimental store

Build
λ go get -u github.com/umayr/zero
λ cd $GOPATH/src/github.com/umayr/zero
λ make

This will create two binary files zero-client and zero-server. You can use as many client as you want, data will be shared among all clients as long as they're connect to same running server.

Supported Types
  • string
  • number
  • array<string|number>
Commands
  • ADD <key> <value>
  • SHOW <*|key>
  • KEYS
  • COUNT
  • DEL <key>
  • PUSH <key> <value>
  • POP <key>
  • EXIT
Example
λ ./build/zero-client
> ADD foo hello
OK
> ADD bar world
OK
> SHOW *
+-----+-------+--------+---------------------+
| KEY | VALUE |  TYPE  |        TIME         |
+-----+-------+--------+---------------------+
| foo | hello | string | 12 Dec 16 05:43 PKT |
| bar | world | string | 12 Dec 16 05:43 PKT |
+-----+-------+--------+---------------------+

> KEYS
[foo bar]
> ADD n 1000
OK
> ADD x 19928300012000
OK
> SHOW *
+-----+----------------+--------+---------------------+
| KEY |     VALUE      |  TYPE  |        TIME         |
+-----+----------------+--------+---------------------+
| n   |           1000 | number | 12 Dec 16 05:43 PKT |
| x   | 19928300012000 | number | 12 Dec 16 05:44 PKT |
| foo | hello          | string | 12 Dec 16 05:43 PKT |
| bar | world          | string | 12 Dec 16 05:43 PKT |
+-----+----------------+--------+---------------------+

> ADD arr [1, 2, 3]
OK
> SHOW arr
[1 2 3]
> PUSH arr hello world
4
> SHOW arr
[1 2 3 hello world]
> SHOW *
+-----+-----------------------+--------+---------------------+
| KEY |         VALUE         |  TYPE  |        TIME         |
+-----+-----------------------+--------+---------------------+
| x   |        19928300012000 | number | 12 Dec 16 05:44 PKT |
| n   |                  1000 | number | 12 Dec 16 05:43 PKT |
| bar | world                 | string | 12 Dec 16 05:43 PKT |
| foo | hello                 | string | 12 Dec 16 05:43 PKT |
| arr | [1 2 3 hello world]   | array  | 12 Dec 16 05:44 PKT |
+-----+-----------------------+--------+---------------------+

> POP arr
hello world
> POP arr
 3
> POP arr
 2
> POP arr
1
> POP arr
err: array is already empty
> KEYS
[foo bar n x arr]
> DEL arr
OK
> COUNT
4
> DEL foo
OK
> DEL n
OK
> SHOW *
+-----+----------------+--------+---------------------+
| KEY |     VALUE      |  TYPE  |        TIME         |
+-----+----------------+--------+---------------------+
| x   | 19928300012000 | number | 12 Dec 16 05:44 PKT |
| bar | world          | string | 12 Dec 16 05:43 PKT |
+-----+----------------+--------+---------------------+

> 
License

MIT

Documentation

Index

Constants

View Source
const (
	String = "string"
	Number = "number"
	Array  = "array"
)
View Source
const (
	RowSplitter    = "|"
	ColumnSplitter = ","
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Args

type Args struct {
	Key   Key
	Type  string
	Value interface{}
}

type Arr

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

func NewArr

func NewArr() *Arr

func (*Arr) Add

func (a *Arr) Add(key Key, values []interface{}) error

func (*Arr) All

func (a *Arr) All() [][]string

func (*Arr) Count

func (a *Arr) Count() int

func (*Arr) Del

func (a *Arr) Del(key Key) error

func (*Arr) Has

func (a *Arr) Has(key Key) bool

func (*Arr) Keys

func (a *Arr) Keys() []Key

func (*Arr) Pop

func (a *Arr) Pop(key Key) (interface{}, error)

func (*Arr) Push

func (a *Arr) Push(key Key, value interface{}) (int, error)

func (*Arr) Show

func (a *Arr) Show(key Key) ([]interface{}, error)

type Key

type Key string

type Num

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

func NewNum

func NewNum() *Num

func (*Num) Add

func (n *Num) Add(key Key, value int64)

func (*Num) All

func (n *Num) All() [][]string

func (*Num) Count

func (n *Num) Count() int

func (*Num) Del

func (n *Num) Del(key Key) error

func (*Num) Keys

func (n *Num) Keys() []Key

func (*Num) Show

func (n *Num) Show(key Key) (int64, error)

type Plug

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

func NewPlug

func NewPlug() *Plug

func (*Plug) Add

func (p *Plug) Add(args *Args, reply *int) (err error)

func (*Plug) Count

func (p *Plug) Count(args *Args, reply *int) (err error)

func (*Plug) Del

func (p *Plug) Del(args *Args, reply *int) (err error)

func (*Plug) Keys

func (p *Plug) Keys(args *Args, reply *[]Key) (err error)

func (*Plug) Pop

func (p *Plug) Pop(args *Args, reply *string) (err error)

func (*Plug) Push

func (p *Plug) Push(args *Args, reply *int) (err error)

func (*Plug) Show

func (p *Plug) Show(args *Args, reply *string) (err error)

type Str

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

func NewStr

func NewStr() *Str

func (*Str) Add

func (s *Str) Add(key Key, value string)

func (*Str) All

func (s *Str) All() [][]string

func (*Str) Count

func (s *Str) Count() int

func (*Str) Del

func (s *Str) Del(key Key) error

func (*Str) Keys

func (s *Str) Keys() []Key

func (*Str) Show

func (s *Str) Show(key Key) (string, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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