Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

parameter_server

C++ and Python wrapper to facilitate key-value store with the Redis database.

Prerequisites

Usage

  • Launch Redis server on 127.0.0.1:6379
  • C++
    • Import the header file into the C++ source file i.e. #include "parameter_server/brosdb.h"
    • The header file contains set() and get() functions to facilitate key-value store in the Redis database.
    • The function set() is declared as follows,
      template<typename T> 
      void set(std::string key, T value);
      and get() as
      template<typename T> 
      void get(std::string key, T *value);
    • The key is expected to of type std::string. Value can be either primitive or user defined.
    • Source file needs to be linked against lhiredis.
  • Python
    • Import setData and getData from brosdb
      from brosdb import setData, getData
    • The module contains setData() and getData() functions to facilitate key-value store in the Redis database.
    • The function setData() is declared as follows,
      def setData(key, value)
      and getData() as
      def getData(key, defaultValue = None)
    • The key is expected to be of type str.

Example

  • C++
    #include <bits/stdc++.h>
    #include "parameter_server/brosdb.h"
    
    int main() {
        int a=5;
        std::string str("foo");
        brosdb::set(str, a);
        int b;
        brosdb::get(str, &b);
        std::cout<<b;
    }
  • Python
    from brosdb import setData, getData
    
    setData("foo", "bar")
    value = getData("foo")
    print(value)