GithubHelp home page GithubHelp logo

andy1978 / go-redis Goto Github PK

View Code? Open in Web Editor NEW

This project forked from markuman/go-redis

0.0 2.0 0.0 138 KB

GNU Octave Redis client (for Matlab too)

License: Do What The F*ck You Want To Public License

MATLAB 21.73% Makefile 3.59% C 74.68%

go-redis's Introduction

THIS IS A FORK FROM https://github.com/markuman/go-redis

go-redis

go-redis - GNU Octave redis client

...but Matlab is supported too. When I don't support Matlab, someone else will do and I have to emulate it with Octave.

Tested with Linux and Mac OS X.

Requirements

  • Classdef support
    • Octave >= 4.0 yeah, not released yet! :)
    • Matlab >= R2012b? (dunno when classdef was introduced...)
  • C-Compiler
  • hiredis library
  • Linux or Mac OS X (never tried with Windows)

Build instructions

Matlab

You can compile it directly in the Matlab commandline.

mex -lhiredis -I/usr/include/hiredis/ CFLAGS='-Wall -Wextra -fPIC -std=c99 -O2 -pedantic -g' redis_.c

Afterwards mv redis_.mex* from mex folder into inst/private folder.

GNU Octave

Best way is to compile it from bash

gcc -fPIC -I /usr/include/octave-3.8.2/octave/ -lm -I /usr/include/hiredis/ -lhiredis -std=c99 -shared -O2 redis_.c -o redis_.mex

Afterwards mv redis_.mex from mex folder into inst/private folder.

Currently (3/19/2015) there is a bug in classdef. You have to do addpath private in octave as a workaround! https://savannah.gnu.org/bugs/?41723

limitations & todo

  • write a Makefile and maybe add hiredis as a submodule to simplify the setup process
  • improve c-code

usage

initialize redis class

>> help redis
 redis mex client for Matlab and GNU Octave
r = redis()
r = redis(hostname) 
r = redis(hostname, port)
r = redis(hostname, port, db)
r = redis(hostname, port, db, pwd)

hostname is type char
port is type double
db is type double (database number)
pwd is type char (auth password)

make a connection
>> r = redis()
	
r = 
	
redis with properties:

hostname: '127.0.0.1'
    port: 6379
      db: 0
     pwd: ''
ping the redis server
    ret = r.ping

    ret =

    PONG
SET

r.set(key, value) value can be a double or a char. doubles will be converted to char.

    ret = r.set('go-redis', 1)

    ret =

    OK
INCR & DECR

r.incr(key)

    ret = r.incr('go-redis')

    ret = 2
GET

r.get(key) return type will always be a char!

    ret = r.get('go-redis')

    ret =

    2
array reply

An array reply will be transformed into a cell array in Octave/Matlab.

    octave:2> r.call('keys *')
    ans =
    {
      [1,1] = b
      [2,1] = A
    }
CALL

r.call(command) for debugging and functions which are not directly supported by go-redis.

deprecated go-redis version

For the older go-redis version - pure written in Octave using instrumen-control package - do git checkout fcf757b

go-redis's People

Contributors

andy1978 avatar dac922 avatar markuman 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.