Code Usage

Learn how to use the Couchbase cache provider in your BoxLang applications using the standard cache functions.

Learn how to use the Couchbase cache provider in your BoxLang applications using the standard cache functions.

🎯 Cache Configuration

Configure Couchbase as a cache provider in your Application.bx:

this.caches["default"] = {
    "provider": "Couchbase",
    "properties": {
        "connectionString": "couchbase://localhost",
        "username": "Administrator",
        "password": "password",
        "bucket": "myapp",
        "scope": "_default",
        "collection": "_default"
    }
};

πŸ“ Basic Operations

Setting Cache Values

Getting Cache Values

Checking Existence

Deleting Cache Values

πŸ” Advanced Operations

Get Multiple Keys

Get All Keys

Get Cache Metadata

🎨 Patterns and Best Practices

Cache-Aside Pattern

Namespace Your Keys

Handle Cache Failures Gracefully

Use Appropriate TTLs

πŸ”„ Integration with Query Caching

🎯 Working with Scopes

Couchbase supports scopes and collections for logical data organization:

πŸ“Š Performance Tips

Batch Operations

Connection Pooling

Connection pooling is automatic! The module manages connections efficiently behind the scenes.

Monitor Cache Performance

πŸ› Debugging

Enable debug logging in your boxlang.json:

πŸ”— Next Steps

Last updated

Was this helpful?