func_redis is an Asterisk module to allow the use of Redis from the dialplan. It depends on the hiredis library.
This project was initially forked from Sergio Medina Toledo's func_redis (https://github.com/tic-ull/func_redis) to add hash operations, authentication and database selection.
It's expected that ongoing changes will make this fork no longer backward-compatible with the original project.
This has been tested with Asterisk 1.8 and 11.
In order to use func_redis you need to configure the settings for the module in the file func_redis.conf. There is an example in samples/func_redis.conf.sample
Example:
[general]
; host of the redis server
; if not defined, use default of 127.0.0.1
hostname=127.0.0.1
; port of the redis server
if not defined, use default of 6379
port=6379
; database index in redis
; if not defined, use default of 0
database=0
; password for redis server
; if not defined, authentication will not be used
;password=s3cr3tp@ssw0rd
; connection time out when connecting to the server
; if not defined, use a default of 5 seconds
timeout=3
; send a BGSAVE on connection close/module unload
; if not defined, use a default of false
bgsave=false
same => n,Set(REDIS(test)=${TEST})
same => n,Set(REDIS(test,field)=${TEST})
same => n,Set(TEST=${REDIS(test)})
same => n,Set(TEST=${REDIS(test,field)})
same => n,NoOp(Deleting test key ${REDIS_DELETE(test)})
same => n,GotoIf(${REDIS_EXISTS(test)}?exists:doesnt_exist)
same => n,Set(REDIS_PUBLISH(channel)=test)
You can use these commands related to func_redis in the Asterisk CLI
-
redis show [pattern]
Shows all of the key values.
[pattern] pattern to match keys
Examples : - h?llo matches hello, hallo and hxllo - h*llo matches hllo and heeeello - h[ae]llo matches hello and hallo, but not hillo
-
redis hshow <hash>
Shows all of the hash's values for a given hash.
-
redis set <key> <value>
Sets the key's value to .
redis set <key> <hash> <value>
Sets the hash's value for a given key .
-
redis del <key>
Deletes the key.