Ortus Couchbase Cache
  • Introduction
  • Intro
    • Release History
      • What's New With 4.0.0
      • 1.1.0 Documentation
      • 1.1.2 Documentation
      • 1.1.3 Documentation
      • 2.0.0 Documentation
      • 3.0.0 Documentation
      • Changelog
    • About This Book
  • Essentials
    • Installation
    • Configuration
    • Usage
      • CFML
      • Scope Storage
      • Direct Java API
      • RAM Resources
    • Debugging
Powered by GitBook
On this page
  • Couchbase Java Cluster
  • Couchbase Java Bucket
  • Ortus Couchbase Java Provider
  1. Essentials
  2. Usage

Direct Java API

Go funky with the Couchbase extension

PreviousScope StorageNextRAM Resources

Last updated 1 year ago

If you need more power or are familiar with the Couchbase Java API and want to use some features we haven't implemented yet, first so we can consider that addition in future version, and then head over to the Java Cluster to get direct access to the Couchbase Java SDK.

Couchbase Java Cluster

The Couchbase extension registers a built-in function (BIF) called couchbaseGetCluster() that you can call anywhere in your application to get a direct reference to the Couchbase Java Cluster that powers the Couchbase extension.

Returns the instance of the Couchbase Java com.couchbase.client.java.Cluster that corresponds with a cache defined in the Lucee admin. Pass in the name of a cache, or it will default to the object cache.

Parameter

Required

Type

Default

Description

cacheName

No

string

---

Definition of the cache used by name, when not set the "default Object Cache" defined in Lucee Administrator is used instead. An error will be thrown if the cache is not a Couchbase cache or does not exist.

Couchbase Java Bucket

The Couchbase extension registers a built-in function (BIF) called couchbaseGetBucket() that you can call anywhere in your application to get a direct reference to the Couchbase Java Bucket that powers the Couchbase extension.

Returns the instance of the Couchbase Java com.couchbase.client.java.Bucket that corresponds with a cache defined in the Lucee admin. Pass in the name of a cache, or it will default to the object cache.

Remember, that there is a Bucket instance for each Couchbase cache defined in the administrator. If you call the couchbaseGetBucket() function with no parameters, you will get the Bucket that corresponds with the default object cache (assuming it is Couchbase). Alternativley, you can pass in a cacheName parameter to specifiy the Couchbase cache connection.

Parameter

Required

Type

Default

Description

cacheName

No

string

---

Definition of the cache used by name, when not set the "default Object Cache" defined in Lucee Administrator is used instead. An error will be thrown if the cache is not a Couchbase cache or does not exist.

// Get the Java Bucket for the default object cache
myBucket = couchbaseGetBucket();

// Get the Java Bucket for the queryStorage cache
myBucket = couchbaseGetBucket( 'queryStorage' );  

Don't forget to javaCast() and realize that you may have issues trying to use the keys that the Extension has set since you are bypassing our serialization schema as well.

Ortus Couchbase Java Provider

For the most part you probably won't need this class, but there are a few methods in the Lucee cache interface that aren't available to you via CFML.

Parameter

Required

Type

Default

Description

cacheName

No

string

---

Definition of the cache used by name, when not set the "default Object Cache" defined in Lucee Administrator is used instead. An error will be thrown if the cache is not a Couchbase cache or does not exist.

// Get the Ortus Java Provider for the default object cache
myProvider = couchbaseGetProvider();

// Get the Ortus Java Provider for the queryStorage cache
myProvider = couchbaseGetProvider( "queryStorage" );  

// Get all keys in the cache as a java.util.List 
keys = myProvider.keys();

// Get all the values in the cache as a java.util.List
values = myProvider.values();

One important thing to note is that values get and set by the Ortus provider will be correctly serialized for you unline direct access to the Couchbase Java client.

The Couchbase Java SDK is fully .

There is one more BIF that the Couchbase extension will register with your Lucee installation. It is called couchbaseGetProvider() and returns an instance to the Java class that Ortus wrote that proxies between the Couchbase client and Lucee. It implements lucee.commons.io.cache.Cache and you can read about its API in the .

let us know
documented here
Lucee /commons/io/cache/Cache.html Lucee API docs