Kamailio module htable: Difference between revisions

From 탱이의 잡동사니
Jump to navigation Jump to search
Line 145: Line 145:
}
}
</pre>
</pre>
== Functions ==


== See also ==
== See also ==

Revision as of 08:24, 28 July 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
}

Functions

See also