Skip to content

Basic in memory key-value store accessible by a HTTP RESTful interface

License

Notifications You must be signed in to change notification settings

vgheri/goCacheIt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goCacheIt Travis CI

Basic in memory key-value store accessible by a HTTP RESTful interface, written in Go.

##Modules

  1. The module responsible for managing the key-value data structure. Main responsibilities include:
  2. Creation of the data structure at start-up
  3. Add a key-value couple
  4. Convert the JSON input to be stored as BSON
  5. Retrieve a value by key
  6. Convert the stored BSON to JSON
  7. The module managing the interface with external clients through a RESTful HTTP API which provides the following methods
  8. POST /api/store/ ⇒ MIME type application/json
  9. body { “key”: stringValue, “value”: { … } }
  10. GET /api/store/?key=my-key ⇒ accepting data type application/json . Result is just the value part {...}

##Implementation details

###Key-value store data structure goCacheIt uses a Splay-tree to store keys and values in memory. The advantage of using a Splay-tree is that frequently accessed nodes are much quicker to retrieve than less ones, making it perfect for a cache system similar. This should also allow for a faster LRU cache eviction policy, as least recently used nodes would obviously be at the bottom of the tree and we could therefore skip many checks in between the root and the leafs.

###Keys Keys are of type string and can have a max length of 255 chars.

###Values The value object is binary encoded as bson to keep spatial overhead to a minimum and consume as few memory resources as possible.

###Data structure details

type Tree struct {
  root *Node  
}
type Node struct {
  *parent, *left, *right Node,
  key string,
  value byte[]
}

About

Basic in memory key-value store accessible by a HTTP RESTful interface

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages