Git Product home page Git Product logo

myriad-kv's Introduction

myriad logo

About

Build Status

Build Status

Description

A distributed key-value store built on top of praetor and legiond

Author

ContainerShip Developers - [email protected]

Modes

myriad-kv can be run in either standalone or embedded mode.

Standalone

In standalone mode, myriad-kv cannot be required from another module directly. All communication must happen over TCP on the given management port.

myriad-kv can be globally installed to be run in standalone mode

npm install -g myriad-kv

The following optional environment variables can be set to configure myriad-kv:

  • MYRIAD_MANAGEMENT_PORT - management port to which client issues commands
  • MYRIAD_PORT - port internode communication will happen on
  • MYRIAD_CIDR - CIDR range to search for other myriad-kv nodes
  • MYRIAD_PUBLIC - forces myriad-kv to listen on 0.0.0.0 and communicate over the public network
  • MYRIAD_DATA_DIRECTORY - path to directory where myriad-kv snapshot will live
  • MYRIAD_SNAPSHOT_NAME - name of snapshot file
  • MYRIAD_MAX_COALESCING_DURATION - duration of period where messages are coalesced before sending

Starting myriad-kv is as simple as running myriad with any desired environment variables set.

Embedded

In embedded mode, myriad-kv is required and instantiated from another node module. Commands can be issued by direct nodejs calls to the API, or over TCP. Issuing calls directly to the embedded API, and avoiding the TCP stack, will result in significant performance benefits.

Include the myriad-kv dependency in your project to run in embedded mode

npm install myriad-kv

Optionally configure myriad-kv by contructing an options object similar to the one below. These configuration parameters are explained above.

var options = {
    legiond: {
        network: {
            port: process.env.MYRIAD_PORT,
            cidr: process.env.MYRIAD_CIDR,
            public: process.env.MYRIAD_PUBLIC
        },
        attributes: {
            management_port: process.env.MYRIAD_MANAGEMENT_PORT
        }
    },
    persistence: {
        max_coalescing_duration: process.env.MYRIAD_MAX_COALESCING_DURATION,
        data_directory: process.env.MYRIAD_DATA_DIRECTORY,
        snapshot_name: process.env.MYRIAD_SNAPSHOT_NAME
    }
}

To start using myriad-kv in your code simply instantiate, configure and start listening:

var Myriad = require("myriad-kv");

var options = {
    legiond: {
        network: {
            cidr: "10.0.10.0/24"
        }
    },
    persistence: {
        data_directory: "/tmp"
    }
}

var myriad = new Myriad(options);
myriad.listen(function(){});

Commands

Below are examples of all commands that can be issued over TCP

KEYS

Get all keys

KEYS
["a::b::c","a::b::d"]

Get keys matching a specific pattern

KEYS a::[a-z]::d
["a::b::d"]

GET

Get a specific key

GET a::b::c
abc

SET

Set a key

SET a::b::a aba

TTL

Retrieve the ttl for a key

TTL a::b::a
{"ttl":-1}

Set the ttl for a key (in ms)

TTL a::b::a 10000

DELETE

Delete a key

DELETE a::b::c

FLUSH

Flushes all keys from the store

FLUSH

Contributing

Pull requests and issues are encouraged!

myriad-kv's People

Contributors

nicktate avatar normanjoyner avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.