THIS IS A FORK FROM https://github.com/markuman/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.
- 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)
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.
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
- write a Makefile and maybe add
hiredis
as a submodule to simplify the setup process - improve c-code
>> 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)
>> r = redis()
r =
redis with properties:
hostname: '127.0.0.1'
port: 6379
db: 0
pwd: ''
ret = r.ping
ret =
PONG
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
r.incr(key)
ret = r.incr('go-redis')
ret = 2
r.get(key)
return type will always be a char!
ret = r.get('go-redis')
ret =
2
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
}
r.call(command)
for debugging and functions which are not directly supported by go-redis.
For the older go-redis version - pure written in Octave using
instrumen-control package - do git checkout fcf757b