I was looking for a toolkit to be able to R/W in a REDIS DB (http://redis.io). I found the labredis VI written by Martijn Jasperse. Based on this, I developed a toolkit offering the most common REDIS commands.
The principle of use is based on the OPEN, COMMANDS and CLOSE VIs.
The REDIS.zip file contains:
- A "Palette" folder, in which all the REDIS commands and those for the Client and Server can be found.
- A "SubVIs" folder, hosting few low level VIs.
- Redis_Example1.vi : showed in the above picture.
- Redis_Example2.vi : to access easily to all the commands (based on polymorphic VIs)
I developed some polymorphic VIs for commands related to:
- Hashes
- Keys
- Lists
- Strings
- Sets
- Sorted sets
- Server
- Publish/Subscribe
- Transactions
- Connections
and few basic functions.
This tollkit was developed on MAC, with LabVIEW 2010, for REDIS 2.8.3 and greater. It should work without any problem on Linux (partially tested) and on Windows (not tested), as it only uses simple LabVIEW functions .
To directly load a command VI (without using the Redis_Example2.vi), for example for the Keys, open the Keys-Commands.vi, from .../Palette/Redis Commands/Keys and select the sub-command to use. The input controls will automatically be adapted to the needs.
You can find all the information and knowledge about REDIS on the web site.
Iwac
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
There is a time-out constant of 100 ms inside "SubVIs/redis-in-LabVIEW.vi". Increase this if you are connecting to a remote server, otherwise the TCP connection will keep getting rejected. Other than this, it works great! Well Done!
Thank you for this feedback.
Iwac.
I get an error "get tdenum from data__ogtk.vi" not found and "type descriptor enumeration__ogtk.ctl" not found when opening the "open redis" from the palette. Is this something related to the toolkit or am i missing something in labview? thanks!!!
EDIT> found it, had to install openg.toolkit!
hi
i'm currently testing the great redis (publish/subscribe) with lots of data on different channels an had 2 different approaches - open redis > publish 10000 measurement data > close redis: in this case the connection was closed after 60 secs. the other approach was to open > publish a single datapackage > close redis: this lead at first to a memory or serial connection error after a while - what would be de preferred way to do this? since it's a tcp connection should the timeout be set to "0" in order to have a unlimited connection? thanks andy
Hi,
I've not done the test, but I think that the first approach would be the good one. I've looked on the Redis support pages and may be something can be configured on the Redis server side, to avoid this limitation (http://redis.io/topics/clients).
hi, thanks for your reply, unfortunatly this does not apply to Pub/Sub clients - i guess we've to try something out to open tcp/ip - broadcast until .... whatever - close the connection. the thing is that this is a real catch in order to have a live broadcasting labview application for (almost) realtime monitoring! thanks again! best andy
Why are you using redis to store binary waveforms using redis? The best approach is to use tdms files. These are fast, can store multiple waveforms, can store meta data and is searchable through the labVIEW Datafinder toolkit or Diadem. Both SQL and NoSQL Databases like REDIS are designed for single point data values. 10000 data points if stored as single precision floating points numbers takes 4 bytes, so a 10000 datapoints should only br about 40kB of data. This should only take a few milliseconds to write to a TDMS file. To take 60 seconds to write such a small amount of data seems both impractical and unecessary. Another nice feature of TDMS files is that you can open it in excel. TDMS is also thread safe, so multiple writer threads can write to the same file.
http://www.ni.com/white-paper/3727/en/
And finally,if you plan to store data on a separate PC, you can use a combination of network streams and TDMS, which will also be fast.
The following link recomends that you store binary data in a file (such as TDMS) and only store the file name is REDIS.
hi
you are definitly right, for massive amount of data we are already using tdms files - redis is just a way to use channels for communication with other systems, storing sessions for our webfrontends and using it as a buffer for logstash to write data into elasticsearch. since there could be a lot of eventdata i tried to check some limits. your api is perfect for that and i found out what the problem was - inserting a 10 ms wait inside my test loop works fine.
thanks a lot!!! best andy
I found a little bug in your helpful library: in file redis-in-LabVIEW.vi, in the case "*" of the case structure on the right, the connection handle is wired with a tunnel connector through the for loop.
It happens that, if I do a HGETALL on an empty hash, the repetition number is 0, so the for loop is not executed and the output handlet is null. Thus, the TCP connection isn't closed, causing a new connection to be opened, runnning out of available connections during long runs.
I replaced it with a shift register, as shown in the screenshot below.
Bye,
Carlo.
Hi,
Can anyone post a Publish/Subscribe example? I am currently publishing messages on the DB but no sucess with the Subscriber. I am getting no data.
Thanks
Zach
The Publish/Subscribe command included in the original library doesn't work, since for this pattern the Redis protocol works in a different way. It follows a push model, and not the typical Request-Response model used other Redis commands.
I developed an example of redis subscription and message handling, built on top of the basic redis-in-labview library. You can find it here:
https://github.com/carlosandroni/RedisLabviewPubSub
Carlo.
Hi,
When I use Redis need to add a password, not just a localhost address(no password), which happened Error.
Error code : redis-in-LabVIEW.vi:3930001<ERR>
REDIS error - NOAUTH Authentication required.
How should I do?
Thanks,
Wen-Chi