Documentation ¶
Overview ¶
Package slowpoke implements a low-level key/value store in pure Go. Keys stored in memory, Value stored on disk
Index ¶
- func Close(file string) (err error)
- func CloseAll() (err error)
- func Count(file string) (uint64, error)
- func Counter(file string, key []byte) (counter uint64, err error)
- func Delete(file string, key []byte) (bool, error)
- func DeleteFile(file string) (err error)
- func Get(file string, key []byte) (val []byte, err error)
- func GetGob(file string, key interface{}, val interface{}) (err error)
- func Gets(file string, keys [][]byte) (result [][]byte)
- func Has(file string, key []byte) (exist bool, err error)
- func Keys(file string, from []byte, limit, offset uint32, asc bool) ([][]byte, error)
- func Open(file string) (db *pudge.Db, err error)
- func Put(file string, key []byte, val []byte) (err error)
- func Set(file string, key []byte, val []byte) (err error)
- func SetGob(file string, key interface{}, val interface{}) (err error)
- func Sets(file string, pairs [][]byte) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
Delete key (always return true) Delete not remove any data from files Return error if any
func DeleteFile ¶
DeleteFile close file key and file val and delete db from map and disk All data will be loss!
func Get ¶
Get return value by key or nil and error Get will open Db if it closed return error if any
func Gets ¶
Gets return key/value pairs in random order result contains key and value Gets not return error if key not found If no keys found return empty result
func Keys ¶
Keys return keys in ascending or descending order (false - descending,true - ascending) if limit == 0 return all keys if offset>0 - skip offset records If from not nil - return keys after from (from not included) If last byte of from == "*" - return keys with this prefix
func Open ¶
Open open/create Db (with dirs) This operation is locked by mutex Return error if any Create .idx file for key storage
func Set ¶
Set store val and key with sync at end File - may be existing file or new If path to file contains dirs - dirs will be created If val is nil - will store only key
Types ¶
This section is empty.
Directories ¶
Path | Synopsis |
---|---|
benchmark
|
|
Examples PUT: # params host/database/store/key and value in body curl -X PUT -H "Content-Type: application/octet-stream" --data-binary "@durov.jpg" localhost:5000/bolt/images/durov curl -X PUT -H "Content-Type: text/html" -d '{"username":"xyz","password":"xyz"}' localhost:5000/bolt/users/user1 curl -X PUT -H "Content-Type: text/html" -d 'some value' localhost:5000/bolt/users/user2 GET: # params host/database/backet/key curl localhost:5000/bolt/images/durov return: bytes curl localhost:5000/bolt/users/user1 return: {"username":"xyz","password":"xyz"} curl -v localhost:5000/bolt/images/durov2 return 404 Error POST: # params host/database/backet/key?cnt=1000&order=desc&vals=false key: first key, possible values "some_your_key" or "some_your_key*" for prefix scan, Last, First - default Last cnt: return count records, default 1000 order: sorting order (keys ordered as strings!), default desc vals: return values, default false curl -X POST localhost:5000/bolt/users return: {"user2","user1"} curl -X POST localhost:5000/bolt/users/ return: {"user1"} curl -X POST "http://localhost:5000/bolt/users/use*?order=asc&vals=true" return: {"user1":"{"username":"xyz","password":"xyz"}","user2":"some value"} curl -X POST "http://localhost:5000/bolt/users/user2?order=desc&vals=true" return: {"user2":"some value","user1":"{"username":"xyz","password":"xyz"}"} DELETE: curl -X DELETE http://localhost:5000/bolt/users/user2 return 200 Ok (or 404 Error if bucket! not found)
|
Examples PUT: # params host/database/store/key and value in body curl -X PUT -H "Content-Type: application/octet-stream" --data-binary "@durov.jpg" localhost:5000/bolt/images/durov curl -X PUT -H "Content-Type: text/html" -d '{"username":"xyz","password":"xyz"}' localhost:5000/bolt/users/user1 curl -X PUT -H "Content-Type: text/html" -d 'some value' localhost:5000/bolt/users/user2 GET: # params host/database/backet/key curl localhost:5000/bolt/images/durov return: bytes curl localhost:5000/bolt/users/user1 return: {"username":"xyz","password":"xyz"} curl -v localhost:5000/bolt/images/durov2 return 404 Error POST: # params host/database/backet/key?cnt=1000&order=desc&vals=false key: first key, possible values "some_your_key" or "some_your_key*" for prefix scan, Last, First - default Last cnt: return count records, default 1000 order: sorting order (keys ordered as strings!), default desc vals: return values, default false curl -X POST localhost:5000/bolt/users return: {"user2","user1"} curl -X POST localhost:5000/bolt/users/ return: {"user1"} curl -X POST "http://localhost:5000/bolt/users/use*?order=asc&vals=true" return: {"user1":"{"username":"xyz","password":"xyz"}","user2":"some value"} curl -X POST "http://localhost:5000/bolt/users/user2?order=desc&vals=true" return: {"user2":"some value","user1":"{"username":"xyz","password":"xyz"}"} DELETE: curl -X DELETE http://localhost:5000/bolt/users/user2 return 200 Ok (or 404 Error if bucket! not found) |