Table of Contents
List of Examples
This module is an implementation of a cache system designed to work with Cassandra servers. It uses the Key-Value interface exported from the core.
memory costs are no longer on the server
many servers can be used inside a cluster, so the memory is virtually unlimited
the cache is 100% persistent. A restart of OpenSIPS server will not affect the DB. The Cassandra DB is also persistent so it can also be restarted without loss of information.
Cassandra is an open-source project so it can be used to exchange data with various other applicationsr
By creating a Cassandra Cluster, multiple OpenSIPS instances can easily share key-value information
The following libraries or applications must be installed before running OpenSIPS with this module loaded:
thrift 0.6.1
Thrift 0.6.1 can be downloaded from http://archive.apache.org/dist/thrift/ Download the archive, extract sources, run ./configure,make,sudo make install.
The urls of the server groups that OpenSIPS will connect to in order to use the from script cache_store,cache_fetch, etc operations. It can be set more than one time. The prefix part of the URL will be the identifier that will be used from the script. The database part of the URL needs to be in the format Keyspace_ColumnFamily
Example 1.1. Set cachedb_url
parameter
... modparam("cachedb_cassandra", "cachedb_url","cassandra:group1://localhost:9061/Keyspace1_Users"); modparam("cachedb_cassandra", "cachedb_url","cassandra:cluster1://random_url:8888/Keyspace2_Keys"); ...
Example 1.2. Use Cassandra servers
... cache_store("cassandra:group1","key","$ru value"); cache_fetch("cassandra:cluster1","key",$avp(10)); cache_remove("cassandra:cluster1","key"); ...
The timeout in ms that will be triggered in case a connection attempt fails.
Example 1.3. Set connection_timeout
parameter
... modparam("cachedb_cassandra", "connection_timeout",1000); ...
The timeout in ms that will be triggered in case a Cassandra write takes too long
The timeout in ms that will be triggered in case a Cassandra read takes too long
Example 1.5. Set receive_timeout
parameter
... modparam("cachedb_cassandra", "receive_timeout",1000); ...
The consistency level desired for write operations. Options are :
1 - Ensure that the write has been written to at least 1 replica's commit log and memory table before responding to the client.
2 - Ensure that the write has been written to N / 2 + 1 replicas before responding to the client.
3 - Ensure that the write has been written to ReplicationFactor / 2 + 1 nodes, within the local datacenter (requires NetworkTopologyStrategy)
4 - Ensure that the write has been written to ReplicationFactor / 2 + 1 nodes in each datacenter (requires NetworkTopologyStrategy)
5 - Ensure that the write is written to all N replicas before responding to the client. Any unresponsive replicas will fail the operation.
6 - Ensure that the write has been written to at least 1 node, including HintedHandoff recipients.
7 - Ensure that the write has been written to at least 2 replica's before responding to the client.
8 - Ensure that the write has been written to at least 3 replica's before responding to the client.
Default is 1
Example 1.6. Set wr_consistency_level
parameter
... modparam("cachedb_cassandra", "wr_consistency_level",7); ...
Due to the fact that Cassandra cannot store counters and regular columns in the same ColumnFamily, add() and sub() methods are not exported through the Key-Value interface.
Also, the module does not currently support Authentication.
Future realeases of this module will address this issue.