Skip to content

CACHEDB_SQL module

This module is an implementation of a cache system designed to work with a regular SQL-based server. It uses the internal DB interface to connect to the back-end, and also implements the Key-Value interface exported from the core.

  • memory costs are no longer on the server
  • the cache is 100% persistent. A restart of OpenSIPS server will not affect the DB. The DB is also persistent so it can also be restarted without loss of information.
  • Multiple OpenSIPS instances can easily share key-value information via a regular SQL-based database
  • The module’s counter operations (ADD and SUB) are currently only supported by MySQL

None.

The following libraries or applications must be installed before running OpenSIPS with this module loaded:

  • none:

The url of the Database that OpenSIPS will connect to in order to use the from script cache_store,cache_fetch, etc operations.

The format to follow is : sql:[conn_id]-dburl

The parameter can be set multiple times to create multiple connections accessible from the OpenSIPS script.

Set db_url parameter
...
modparam("cachedb_sql", "cachedb_url", "sql:1st-mysql://root:vlad@localhost/opensips_sql")
...
Usage example
...
modparam("cachedb_sql", "cachedb_url", "sql:1st-mysql://root:vlad@localhost/opensips_sql")
modparam("cachedb_sql", "cachedb_url", "sql:2nd-postgres://root:vlad@localhost/opensips_pg")
...
...
cache_store("sql:1st-mysql","key","$ru value");
cache_store("sql:2nd-postgres","counter","10");
...

The table of the Database that OpenSIPS will connect to in order to use the from script cache_store,cache_fetch, etc operations.

Set db_url parameter
...
modparam("cachedb_sql", "db_table","my_table");
...

The column where the key will be stored

Set key_column parameter
...
modparam("cachedb_sql", "key_column","some_name");
...

The column where the value will be stored

Set value_column parameter
...
modparam("cachedb_sql", "value_column","some_name");
...

The column where the counter value will be stored

Set counter_column parameter
...
modparam("cachedb_sql", "counter_column","some_name");
...

The column where the expires will be stored

Set expires_column parameter
...
modparam("cachedb_sql", "expires_column","some_name");
...

The interval in seconds at which the expired keys will be removed from the database. Default value is 60 ( seconds )

Set cache_clean_period parameter
...
modparam("cachedb_sql", "cache_clean_period",10);
...

The module does not export functions to be used in configuration script.

Q: What happened with the old “db_url” module parameter?

It was replaced with the “cachedb_url” parameter. See the documentation for the usage of the “cachedb_url” parameter.

doc copyrights:

Top contributors by DevScore(1), authored commits(2) and lines added/removed(3)

#NameDevScoreCommitsLines++Lines—
1.Vlad Paiu (@vladpaiu)165100692
2.Stefan Darius (@dariusstefan)7422122
3.Liviu Chircu (@liviuchircu)642947
4.Razvan Crainea (@razvancrainea)5344
5.Bogdan-Andrei Iancu (@bogdan-iancu)5342
6.Julián Moreno Patiño3122
7.Dusan Klinec (@ph4r05)3122

(1) DevScore = author_commits + author_lines_added / (project_lines_added / project_commits) + author_lines_deleted / (project_lines_deleted / project_commits)

(2) including any documentation-related commits, excluding merge commits

(3) ignoring whitespace edits, renamed files and auto-generated files

#NameCommit Activity
1.Stefan Darius (@dariusstefan)Jun 2026 - Jul 2026
2.Razvan Crainea (@razvancrainea)Aug 2015 - Jun 2026
3.Bogdan-Andrei Iancu (@bogdan-iancu)Oct 2014 - Jun 2018
4.Liviu Chircu (@liviuchircu)Mar 2014 - Jun 2018
5.Julián Moreno PatiñoFeb 2016 - Feb 2016
6.Dusan Klinec (@ph4r05)Dec 2015 - Dec 2015
7.Vlad Paiu (@vladpaiu)Jan 2013 - May 2014

(1) including any documentation-related commits, excluding merge commits

Last edited by: Razvan Crainea (@razvancrainea), Bogdan-Andrei Iancu (@bogdan-iancu), Liviu Chircu (@liviuchircu), Julián Moreno Patiño, Vlad Paiu (@vladpaiu).

All documentation files (i.e. .md extension) are licensed under the Creative Common License 4.0