Kamailio module htable: Difference between revisions
(2 intermediate revisions by the same user not shown) | |||
Line 16: | Line 16: | ||
'''Example''' | '''Example''' | ||
<pre> | <pre> | ||
# Dump $sht(students=>alice) | # Dump $sht(students=>alice) | ||
kamcmd htable.get students alice | kamcmd htable.get students alice | ||
Line 22: | Line 21: | ||
# Dump first entry in array key course $sht(students=>source[0]) | # Dump first entry in array key course $sht(students=>source[0]) | ||
kamcmd htable.get students course[0] | kamcmd htable.get students course[0] | ||
</pre> | </pre> | ||
Line 34: | Line 32: | ||
'''Example''' | '''Example''' | ||
<pre> | <pre> | ||
# Delete $sht(student=>alice) | # Delete $sht(student=>alice) | ||
kamcmd htable.delete students alice | kamcmd htable.delete students alice | ||
Line 52: | Line 49: | ||
'''Example''' | '''Example''' | ||
<pre> | <pre> | ||
# Set $sht(test->x) as string | # Set $sht(test->x) as string | ||
kamcmd htable.sets test x abc | kamcmd htable.sets test x abc | ||
Line 58: | Line 54: | ||
# Set first entry in array key x $sht(test=>x[0]) as string | # Set first entry in array key x $sht(test=>x[0]) as string | ||
kamcmd htable.sets | kamcmd htable.sets | ||
</pre> | </pre> | ||
Line 87: | Line 82: | ||
'''Example''' | '''Example''' | ||
<pre> | <pre> | ||
kamcmd htable.dump ipban | kamcmd htable.dump ipban | ||
</pre> | </pre> | ||
Line 114: | Line 107: | ||
</pre> | </pre> | ||
=== htable.listTables === | |||
Lists all defined tables. | Lists all defined tables. | ||
Line 145: | Line 138: | ||
} | } | ||
</pre> | </pre> | ||
== Functions == | |||
== See also == | == See also == |
Latest revision as of 08:24, 2 August 2019
Overview
Kamailio module htable 내용 정리.
Basic
This module adds a hash table container to the configuration language. The hash table is stored in shared memory and the access to it can be done via pseudo-variables: $sht(htname=>name). The module supports definition of many hash tables and can load values at startup from a database table.
RPC Commands
htable.get htable key
Lists one value in a hash table.
Parameters
- htable: Name of the hash table to dump.
- key: Key name of the hash table value to dump.
Example
# Dump $sht(students=>alice) kamcmd htable.get students alice # Dump first entry in array key course $sht(students=>source[0]) kamcmd htable.get students course[0]
htable.delete htable key
Delete one value in a hash table.
Parameters
- htable: Name of the hash table to delete.
- key: Key name of the hash table value to delete.
Example
# Delete $sht(student=>alice) kamcmd htable.delete students alice # Delete first entry in array key course $sht(students=>course[0]) kamcmd htable.delete students course[0]
htable.sets htable key value
Set an item in hash table to string value.
Parameters
- htable: Name of the hash table.
- key: Key name in the hash table.
- value: String value for the item.
Example
# Set $sht(test->x) as string kamcmd htable.sets test x abc # Set first entry in array key x $sht(test=>x[0]) as string kamcmd htable.sets
htable.seti htable key value
Set an item in hash table to integer value.
Parameters
- htable: Name of the hash table.
- key: Key name in the hash table.
- value: Integer value for the item.
Example
... # Set $sht(test=>x) as integer kamcmd htable.seti test x 123 # Set first entry in array key x $sht(test=>x[0]) as integer kamcmd htable.seti test x[0] 123
htable.dump htable
Lists all the values in a hash table.
Parameters
- htable: Name of the hash table to dump.
Example
kamcmd htable.dump ipban
htable.reload htable
Reload hash table from database
Parameters
- htable: Name of the hash table to reload.
Example
kamcmd htable.reload ipban
htable.flush htable
Empty the hash table.
Parameters
- htable: Name of the hash table to flush.
Example
kamcmd htable.flush ipban
htable.listTables
Lists all defined tables.
Example
$ sudo kamcmd htable.listTables { name: ipban dbtable: dbmode: 0 expire: 300 updateexpire: 1 size: 256 dmqreplicate: 0 }
htables.stats
Get statistics for hash tables - name, number of slots, number of items, max number of items per slot, min number of items per slot.
Example
$ sudo kamcmd htable.stats { name: ipban slots: 256 all: 0 min: 0 max: 0 }