Configure Caching

Razuna Cache Configuration

As of Razuna 1.5, we introduced different caching options. Caching can make a huge performance difference to your application by reducing the overhead associated with producing repeated blocks of functionality. Using a cache inside of Razuna is extremely easy, allowing you a wide variety of ways to not only access the cache, but how you manage and store this cache using both memory, disk, Memcached, MongoDB and CouchBase.

:white_check_mark: Default Cache
By default, Razuna uses caching already within the “Memory” and “Disk” configuration. You only need to change this if you want to use another caching mechanism like Memcached, MongoDB or CouchBase!

Configure Cache

Changed the default cache configuration is fairly simply. All you need to do is to edit the file “Server.cfc” (located in the WEB-INF folder). Within that file use one of the below configuration options (they should already be in there commented).

Memcached/CouchBase

This cache uses a remote memcached (or CouchBase) server as its storage mechanism. The size of this cache is controlled by the server, with items being auto-aged to make room for new items.

<cfset cacheregionnew(
    region="razcache",
    props=
        {
        type : 'memcached',
        server : '127.0.0.1:11211',
        waittimeseconds : 5
        }
)>

server is the list of one or more memcached servers that the cache will connect to.
waittimeseconds is the time that Razuna will wait for before cancelling the operation to the server.
If all the servers go away, then the system will operate as normal, except the cache will simply return nothing.

MongoDB

Using a MongoDB as a caching server is an effective use of this powerful remote document store. Razuna utilises the MongoDB architecture as efficiently as possible, ensuring the minimum overhead is placed in the cache management.

<cfset cacheregionnew(
    region="razcache",
    props=
        {
    type : 'mongo',
    server : '10.0.0.1:27017 10.0.0.2:27017',
    db : 'razcache',
    collection : 'nameofregion',
    user : 'username',
    password : 'password'
    }
)>

server is the list of MongoDB servers that will be used. This is designed to utilise replica shards.
db is the name of the database, which defaults to ‘razcache’.
collection is the name of the collection to use, which defaults to the name of the cache region when created.
user if the remote MongoDB is protected by a username/password, this is the username.
password password if protected

:exclamation: You need to restart the Razuna server in order to apply the change!