For the complete documentation index, see llms.txt. This page is also available as Markdown.

Scope Storage

Use Couchbase as the storage backend for BoxLang session and application scopes, providing distributed, fault-tolerant scope storage that scales across multiple servers.

Use Couchbase as the storage backend for your BoxLang session and application scopes. This provides distributed, fault-tolerant scope storage that survives application restarts and scales across multiple servers.

🎯 Session Storage

Configuration

Configure Couchbase as your session storage provider in Application.bx:

component {
    this.name = "MyApp";
    this.sessionManagement = true;
    this.sessionStorage = "couchbase-sessions";
    this.sessionTimeout = createTimeSpan(0, 2, 0, 0); // 2 hours

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

Using Session Scope

Once configured, use the session scope normally:

Benefits

  • βœ… Distributed: Sessions survive server restarts

  • βœ… Scalable: Share sessions across multiple servers

  • βœ… Fast: Sub-millisecond access times

  • βœ… Secure: Sessions stored in dedicated collection

🌐 Application Scope Storage

Configuration

Using Application Scope

πŸ”§ Advanced Configuration

Separate Collections for Different Scope Types

Session Clustering

For load-balanced applications:

πŸ“Š Monitoring Session Activity

Query Active Sessions

Find Sessions by User

🧹 Session Cleanup

Manual Cleanup

Automatic Expiration

Configure TTL (Time To Live) at the cache level:

πŸ” Security Best Practices

1. Use Dedicated Credentials

2. Use TLS/SSL

3. Separate Sensitive Data

🎯 Performance Optimization

Session Granularity

Lazy Loading

πŸ› Troubleshooting

Sessions Not Persisting

Check that sessionStorage matches your cache name:

Connection Errors

Verify Couchbase is running and accessible:

Performance Issues

Monitor cache statistics:

πŸ”— Next Steps

Last updated

Was this helpful?