Skip to content

A ColdBox module that adds support for Couchbase Server as a CacheBox Provider

Notifications You must be signed in to change notification settings

coldbox-modules/cbox-cachebox-couchbase-provider

Repository files navigation

Hex.pm TestBox ColdBox Build Status

CacheBox Couchbase Provider Module

The Couchbase Provider for Cachebox is a ColdBox 4.x module that allows you to connect CacheBox to a Couchbase cluster and leverage that cluster in your ColdBox applications.

LICENSE

Apache License, Version 2.0.

IMPORTANT LINKS

SYSTEM REQUIREMENTS

  • Lucee 4.5+
  • ColdFusion 11+
  • ColdBox 4.x

INSTRUCTIONS

Just drop into your modules folder or use CommandBox to install

box install couchbase-cachebox-provider

This will install our module and its dependenices into your modules folder.

Settings

You can add a couchbaseCacheBoxProvider structure to your moduleSettings structure to your ColdBox.cfc to configure custom caches. Each cache region you define follows the same approach as registering custom caches in CacheBox (https://cachebox.ortusbooks.com/content/cachebox_configuration/caches.html). The only difference, is that the properties for the cache are basically the properties for the cfcouchbase SDK to use for connecting to a bucket.

Each cache region has a different CouchbaseClient instance configured for operation (https://cfcouchbase.ortusbooks.com/configuration/config_settings.html). Below are the basic configuration properties. Please refer to the documentation or API docs for further information about the cfcouchbase SDK (http://apidocs.ortussolutions.com.s3.amazonaws.com/cfcouchbase/2.0.0/cfcouchbase/config/CouchbaseConfig.html)

This provider also comes with two cache implementations you can use when defining caches:

  • CouchbaseProvider - Implements the CacheBox provider interface and can interact with Couchbase
  • CouchbaseColdboxProvider - Implements the ColdBox CacheBox provider which allows it to be used for event and view caching as a template cache.
moduleSettings = {

	// Provider Configuration Settings
	couchbaseCacheBoxProvider = {
		// Register all the custom named caches you like here using CacheBox Syntax
		// https://cachebox.ortusbooks.com/content/cachebox_configuration/caches.html
		caches : { 
			"template" : {
				provider 	: "couchbaseCacheboxProvider.models.CouchbaseColdBoxProvider",
				properties 	: {
					// The default timeout for cache entries
					objectDefaultTimeout    : 120,
					// Ignores timeouts on Couchbase operations due to async natures
					ignoreCouchbaseTimeouts : true,
					// The bucketname in Couchbase to store cache entries under, the default value is 'default'
					bucketName              : "default",
					// The list of servers in the Couchbase cluster
					servers					: "127.0.0.1:8091",
					// The username for the Couchbase bucket, if any
					username				: "",
					// The password for the Couchbase bucket, if any
					password				: ""
				}
			},
			"couchBase" : {
				provider 	: "couchbaseCacheboxProvider.models.CouchbaseProvider",
				properties 	: {
					// The default timeout for cache entries
					objectDefaultTimeout    : 120,
					// Ignores timeouts on Couchbase operations due to async natures
					ignoreCouchbaseTimeouts : true,
					// The bucketname in Couchbase to store cache entries under, the default value is 'default'
					bucketName              : "default",
					// The list of servers in the Couchbase cluster
					servers					: "127.0.0.1:8091",
					// The username for the Couchbase bucket, if any
					username				: "",
					// The password for the Couchbase bucket, if any
					password				: ""
				}
			}
		}
	}
}

Please remember that you can pass any name-value pair in the properties struct to configure the couchbase SDK according to the CouchbaseClient object: http://apidocs.ortussolutions.com.s3.amazonaws.com/cfcouchbase/2.0.0/cfcouchbase/config/CouchbaseConfig.html


Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp www.coldbox.org | www.luismajano.com | www.ortussolutions.com


HONOR GOES TO GOD ABOVE ALL

Because of His grace, this project exists. If you don't like this, then don't read it, its not for you.

"Therefore being justified by faith, we have peace with God through our Lord Jesus Christ: By whom also we have access by faith into this grace wherein we stand, and rejoice in hope of the glory of God. And not only so, but we glory in tribulations also: knowing that tribulation worketh patience; And patience, experience; and experience, hope: And hope maketh not ashamed; because the love of God is shed abroad in our hearts by the Holy Ghost which is given unto us. ." Romans 5:5

THE DAILY BREAD

"I am the way, and the truth, and the life; no one comes to the Father, but by me (JESUS)" Jn 14:1-12