Giter VIP home page Giter VIP logo

lightning's Introduction

Lightning

Lightning Fast Shared Memory Key-Value Store

Lightning is an easy to use single-header library that allows for fast IPC through a shared memory key-value store.

Installation:

Move lightning.hh to your project directory and add #include "lightning.hh" at the top of files where you will use it.

Then, compile with -pthread.

Usage:

Lightning::init() Maps the store into the memory of the calling process. (also creates the store if it does not already exist)

Lightning::set(char *key, char *value) sets "key" to "value" in the store.

Lightning::get(char *key) Returns a pointer to the value associated with key in shared memory.

Lightning::rm(char *key) Removes and frees the entry associated with key.

Lightning::detach() Unmaps the shared memory from the calling processes memory.

Lightning::close() Unmaps the shared memory from the calling processes memory, then destorys the shared memory.

Example:

programA.cc

#include "lightning.hh"
#include <iostream>
#include <stdio.h>

int main()
{
    Lightning lightning;

    lightning.init();

    lightning.set("test_key", "test_value");
    printf("set test_key: test_value\n");

    lightning.detach();

    return 0;
}

programB.cc

#include "lightning.hh"
#include <iostream>
#include <stdio.h>

int main()
{
    Lightning lightning;

    lightning.init();

    char *value = lightning.get("test_key");
    printf("get test_key: %s\n", value);

    lightning.rm("test_key");
    printf("removed test_key\n");

    lightning.close();

    return 0;
}

lightning's People

Contributors

3intermute avatar

Stargazers

 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.