BoxLang 🚀 A New JVM Dynamic Language Learn More...
|:------------------------------------------------------: |
| ⚡︎ B o x L a n g ⚡︎
| Dynamic : Modular : Productive
|:------------------------------------------------------: |
This module provides enterprise-grade Couchbase cache providers and AI vector memory capabilities for BoxLang runtimes. Store cache data, sessions, and vector embeddings in Couchbase's distributed NoSQL database with built-in vector search support.
To include the module in your boxlang runtime, follow the
instructions for module installation appropriate to your
runtime, using bx-couchbase as the module name/slug.
Versions 1.0.0 and above will require a Boxlang+ Subscription. Without
subscription, the module will operate within trial mode for 30 days.
After this period, the module will be placed in developer mode, which
will limit cache host connections only to 127.0.0.1 and localhost.
Feature Requests and Bug Reports may be submitted via JIRA.
If you file a bug report, your issue should contain a title, a clear description of the issue, a way to replicate the issue, and any support files that we might need to replicate your issue. The goal of a bug report is to make it easy for yourself - and others - to replicate the bug and develop a fix for it. All issues that do not contain a way to replicate will not be addressed.
If you have any questions on usage, professional support or just ideas to bounce off the maintainers, please do not create an issue. Leverage our support channels first.
boxlang.json configurationThe JSON configuration structure for boxlang for a Couchbase
connection would be placed in the caches object in boxlang.json
{
"caches" : {
"sessions": {
"provider": "Couchbase",
"properties": {
"cacheKeyCaseSensitivity": "false",
"connectionString": "couchbase://127.0.0.1",
"username": "Administrator",
"password": "password",
"bucket": "default",
"scope": "myAppName",
"collection": "sessions",
"connectTimeout": "10000",
"kvTimeout": "2500",
"queryTimeout": "75000"
}
}
}
}
couchbase://localhost, couchbases://cluster.example.com)_default)_default)false)10000)2500)75000)true for couchbases://)couchbase://hostname or couchbase://hostname:11210
couchbase://node1,node2,node3
couchbases://hostname (uses TLS){
"caches" : {
"resources": {
"provider": "Couchbase",
"properties": {
"connectionString": "couchbases://node1.myc cluster.com,node2.mycluster.com,node3.mycluster.com",
"username": "${COUCHBASE_USERNAME}",
"password": "${COUCHBASE_PASSWORD}",
"bucket": "myapp",
"connectTimeout": "15000",
"kvTimeout": "3000",
"cacheKeyCaseSensitivity": "false"
}
}
}
}
Application.bx/Application.cfc configurationthis.caches[ "sessions" ] = {
"provider": "Couchbase",
"properties": {
"cacheKeyCaseSensitivity": "false",
"connectionString": "couchbase://127.0.0.1",
"username": "Administrator",
"password": "password",
"bucket": "default",
"scope": "_default",
"collection": "_default",
"connectTimeout": "10000",
"kvTimeout": "2500",
"queryTimeout": "75000"
}
};
this.caches[ "resources" ] = {
"provider": "Couchbase",
"properties": {
"connectionString": "couchbases://node1.mycluster.com,node2.mycluster.com",
"username": myClusterUsername,
"password": myClusterPassword,
"bucket": "myapp",
"connectTimeout": "15000",
"kvTimeout": "3000",
"cacheKeyCaseSensitivity": "false"
}
};
The Couchbase connection string. Format:
couchbase://host or couchbases://host for
secure connections. Can include multiple nodes: couchbase://node1,node2,node3
The username for authentication with the Couchbase cluster.
The password for authentication with the Couchbase cluster.
The name of the Couchbase bucket to use for cache storage.
The scope within the bucket (default: _default). Scopes
provide logical grouping of collections.
The collection within the scope (default: _default).
Collections are like tables in a bucket.
Whether cache keys should be case-sensitive (default: false).
10000)2500)75000)Maximum number of connections to maintain in the connection pool (optional).
Maximum number of connections to maintain in the connection pool (optional).
By default all cache keys are transformed to lowercase to avoid any
casing issues. However, if you want case sensitivity, then turn this
option on by setting cacheKeyCaseSensitivity to true.
// Configure a Couchbase cache
this.caches["default"] = {
"provider": "Couchbase",
"properties": {
"connectionString": "couchbase://localhost",
"username": "Administrator",
"password": "password",
"bucket": "default"
}
};
// Use it!
cacheSet("myKey", { name: "John", age: 30 });
user = cacheGet("myKey");
// Vector search with AI embeddings
embedding = getOpenAIEmbedding("search text");
results = couchbaseVectorSearch(
cacheName = "default",
collection = "default._default._default",
embedding = embedding,
limit = 10
);
// Distributed locking across servers
couchbaseLock(
cacheName = "default",
name = "payment-#orderId#",
timeout = 5,
expires = 30,
callback = function() {
// Only one server processes this at a time
processPayment(orderId);
}
);
couchbaseGetProvider() - Get cache provider instancecouchbaseGetCluster() - Get Java Cluster instancecouchbaseGetBucket() - Get Java Bucket instancecouchbaseGetScope() - Get Java Scope instancecouchbaseGetCollection() - Get Java Collection instancecouchbaseVectorSearch() - Semantic vector search with KNNcouchbaseVectorAdd() - Store vector documents with embeddingscouchbaseVectorGet() - Retrieve vector document by IDcouchbaseVectorDelete() - Delete vector documentcouchbaseVectorList() - List vector documents with filterscouchbaseQuery() - Execute raw N1QL/SQL++ queriescouchbaseLock() - Acquire distributed lock with
optional callbackcouchbaseUnlock() - Release distributed lock manuallySee the API Usage Documentation and Distributed Locking Guide for detailed examples.
Copyright Since 2023 by Ortus Solutions, Corp
www.boxlang.io | www.ortussolutions.com
BoxLang is a professional open-source project and it is completely funded by the community and Ortus Solutions, Corp. Ortus Patreons get many benefits like a cfcasts account, a FORGEBOX Pro account and so much more. If you are interested in becoming a sponsor, please visit our patronage page: https://patreon.com/ortussolutions
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
couchbaseLock() and couchbaseUnlock() BIFsCouchbaseLock component for automatic lock managementcouchbaseGetProvider, couchbaseGetCluster, etc.)couchbaseQuery() BIF
$
box install bx-couchbase