Redis client for Miva. This only supports running on Linux.
Simply run "docker-compose up" in this directory to spool up a dev environment for working on this module. Access the wwwroot folder by going to http://localhost:8080. All .mv files in the wwwroot directory will be compiled by the mivascript compiler whenever a change is detected. All .mv files have access to the miva-redis module.
- cpp-compiler
- Watches for changes to the src/**/*.cpp files, and runs "make" when changes are directed. Output is set to ./src/bin, and also copied to the /data/builtins directory
- miva-compiler
- Watches for changes to the wwwroot/**/*.mv files, and compiles them into .mvc files on change. References the /data/builtins directory so that it can see the compiled miva-redis binary.
- miva-empresa
- An apache server configured with the empresa engine in CGI mode, seving out the ./wwwroot directory. References the /data/builtins directory so that it can execute the miva-redis binary.
- redis
- An instance of a redis server available in the miva-empresa container using the hostname "redis".
- Compile for your target architecture/linux kernel/distro
- Either:
- Copy
miva-redis.so
into your builtins directory for your mivavm OR - Add
<BUILTIN-LIB LIBRARY = "/path/to/miva-redis.so">
to yourmivavm.conf
file
- Copy
- Add a
redis.dat
file to yourmivadata
directory with either of the formats:host:port
ORhost:port:db
wheredb
is the database index to connect to
- Congrats! You can now use the
redis_*
commands! miva-redis will use theredis.dat
file to automatically connect to the server the first time you try to use aredis_*
command. Ifredis.dat
doesn't exist, or there is an error, allredis_*
commands will fail silently.
command: the command format to send to redis. You can use ? as substitions.
args: a comma seperated list of variable names, all starting with either l.
or g.
, that will be substituted into ? placeholders for the command.
Returns 0
on error, otherwise returns a redis_reply. See formatRedisReply
and https://github.com/redis/hiredis#using-replies for more information.
<MvAssign name="l.data" value="HEY THERE!" />
<MvAssign name="l._" value="{redis_command('SET key ?', 'l.data')}" />
<MvAssign name="l.data" value="{redis_command('GET key', '')}" />
<MvEval expr="{l.data:string}" />
See redis_command
and https://github.com/redis/hiredis#pipelining
message: if there is an error, this variable is filled with the error message.
If there is an error, returns a non-zero error code. Otherwise, returns 0
.
Clears the last redis error.
Disconnects from redis. Returns 1
on success, 0
on failure. Note that you shouldn't have to call this function. I don't know why I made it.
See https://github.com/redis/hiredis#pipelining
If a redis conneciton has not yet been attempted, attempts to connect using the information provided in mivadata/redis.dat
. If no mivadata/redis.dat
file is present, or the connection fails, returns 0
.
If a redis connection has been attempted, returns 1
or 0
depending on if the connection was successful.
Wrapper around APPEND.
key: the key to append to.
value: a reference to the string to append.
Returns 0
on error, 1
on success.
Wrapper around DEL.
key: the key to delete (todo: accept arrays too).
Returns 0
on error, 1
on success.
Wrapper around GET.
key: the key to get.
ret: the value of the key will be placed in this variable.
Returns 0
on error, -1
if the key was not found, and 1
if the key was found.
Wrapper around SET.
key: the key to set.
value: a reference to the string to set the key to.
Returns 0
on error, 1
on success.
Wrapper around SETEX.
key: the key to set.
value: a reference to the string to set the key to.
expires: the expiration of the key in seconds.