[sr-dev] git:master:d4cd7711: db_redis: docs about keys format and sample records

Daniel-Constantin Mierla miconda at gmail.com
Mon Sep 24 15:40:24 CEST 2018

Module: kamailio
Branch: master
Commit: d4cd77119b55478a6bd35b76a9e7c196c0a71698
URL: https://github.com/kamailio/kamailio/commit/d4cd77119b55478a6bd35b76a9e7c196c0a71698

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-09-24T15:39:27+02:00

db_redis: docs about keys format and sample records


Modified: src/modules/db_redis/doc/db_redis_admin.xml


Diff:  https://github.com/kamailio/kamailio/commit/d4cd77119b55478a6bd35b76a9e7c196c0a71698.diff
Patch: https://github.com/kamailio/kamailio/commit/d4cd77119b55478a6bd35b76a9e7c196c0a71698.patch


diff --git a/src/modules/db_redis/doc/db_redis_admin.xml b/src/modules/db_redis/doc/db_redis_admin.xml
index f57fa8064e..12d054712a 100644
--- a/src/modules/db_redis/doc/db_redis_admin.xml
+++ b/src/modules/db_redis/doc/db_redis_admin.xml
@@ -67,6 +67,15 @@ username/string,domain/string,contact/string,received/string,path/string,expires
 			also write mappings besides the actual records for billing systems to
 			correlate start and stop records faster).
+		<para>
+			The key is always prefixed with 'tablename:entry::'. For example the record in
+			'subscriber' table for user 'alice at sip.com' has the key:
+			'subscriber:entry::alice:sip.com'. If all the records are just loaded at
+			startup (or all reloaded at runtime), the key can just be made unique using whatever
+			values added after 'tablename:entry::' prefix. For example, keys for 'address' table
+			records can be: 'address:entry::1', address:entry::2', address:entry::3', ... No
+			'keys' modparam of 'db_redis' for 'address' table needs to be defined.
+		</para>
 			The mappings can be freely defined in the "keys" module parameter, which is
 			composed of a semi-colon separated list of definitions in the format
@@ -165,7 +174,7 @@ modparam("db_redis", "keys", "version=entry:table_name;location=entry:ruid&u
 			Load the module and set the "db_url" modparam for specific modules to:
-			redis://[username]@host:port/database. Username is optional.
+			'redis://[username]@host:port/database'. Username is optional.
 			The database portion must be a valid Redis database number.
@@ -177,17 +186,44 @@ loadmodule "db_redis.so"
 #!define DBURL_USRLOC "redis://"
 #!define DBURL_ACC    "redis://"
 #!define DBURL_AUTH   "redis://"
+#!define DBURL_PERM   "redis://"
 modparam("db_redis", "schema_path", "/usr/share/kamailio/db_redis/kamailio")
 modparam("db_redis", "keys", "location=entry:ruid&usrdom:username,domain&timer:partition,keepalive")
 modparam("db_redis", "keys", "acc=entry:callid,time_hires&cid:callid")
 modparam("db_redis", "keys", "subscriber=entry:username,domain")
 modparam("usrloc", "db_url", DBURL_USRLOC)
 modparam("acc_db", "db_url", DBURL_ACC)
 modparam("auth_db", "db_url", DBURL_AUTH)
+modparam("permissions", "db_url", DBURL_PERM)
+		<para>
+		Samples adding records for address table using 'redis-cli':
+		</para>
+		<example>
+			<title>Usage</title>
+			<programlisting format="linespecific">
+HMSET address:entry::1 id 1 grp 1 ip_addr "" mask 32 port 0
+HMSET address:entry::2 id 2 grp 1 ip_addr "" mask 32 port 0
+HMSET address:entry::3 id 3 grp 2 ip_addr "" mask 32 port 0
+HMSET address:entry::4 id 4 grp 2 ip_addr "" mask 32 port 0 tag "test"
+			</programlisting>
+		</example>
+		<para>
+		Note that is some cases, the optional values in database tables can be
+		ommitted. For 'address' table, the 'tag' value may be ommitted. To avoid
+		any issues, set unused fields to their default values as defined by database
+		schema. When definition allows 'NULL', that field can be unset.
+		</para>

More information about the sr-dev mailing list