[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>
+		<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>
 		<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
 		<title>Usage</title>
 		<para>
 			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.
 		</para>
 		<example>
@@ -177,17 +186,44 @@ loadmodule "db_redis.so"
 #!define DBURL_USRLOC "redis://127.0.0.1:6379/5"
 #!define DBURL_ACC    "redis://127.0.0.1:6379/6"
 #!define DBURL_AUTH   "redis://127.0.0.1:6379/7"
+#!define DBURL_PERM   "redis://127.0.0.1:6379/8"
 ...
 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)
 ...
 			</programlisting>
 		</example>
+		<para>
+		Samples adding records for address table using 'redis-cli':
+		</para>
+		<example>
+			<title>Usage</title>
+			<programlisting format="linespecific">
+...
+SELECT 8
+HMSET address:entry::1 id 1 grp 1 ip_addr "127.0.0.1" mask 32 port 0
+HMSET address:entry::2 id 2 grp 1 ip_addr "127.0.0.2" mask 32 port 0
+HMSET address:entry::3 id 3 grp 2 ip_addr "127.0.0.3" mask 32 port 0
+HMSET address:entry::4 id 4 grp 2 ip_addr "127.0.0.4" 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>
 	</section>
 
 	<section>




More information about the sr-dev mailing list