> For the complete documentation index, see [llms.txt](https://cfcouchbase.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cfcouchbase.ortusbooks.com/installation/traditional-apps.md).

# Traditional Apps

Download the SDK from the following sources or use CommandBox: `box install cfcouchbase` to install the SDK

* Official Releases: <http://www.ortussolutions.com/products/cfcouchbase>&#x20;
* Source: <https://github.com/Ortus-Solutions/cfcouchbase-sdk> Github
* Bleeding Edge + More: <http://integration.stg.ortussolutions.com/artifacts/ortussolutions/cfcouchbase/>

## The Mapping

The CFCouchase SDK is contained in a single folder. The easiest way to install it is to copy `cfcouchbase` in the web root. For a more secure installation, place it outside the web root and create a mapping called `cfcouchbase`.

```
this.mappings[ '/cfcouchbase' ] = 'C:\path\to\cfcouchbase';
```

Now that the code is in place, all you need to do is create an instance of `cfcouchbase.CouchbaseClient` for each bucket you want to connect to. The `CouchbaseClient` class is thread safe and you only need one instance per bucket for your entire application. It is recommended that you store the instantiated client in a persistent scope such as `application` when your app starts up so you can access it easily.

```
public boolean function onApplicationStart(){
    application.couchbase = new cfcouchbase.CouchbaseClient();
    return true;
}
```

## WireBox

However, we would recommend you use a dependency injection framework like [WireBox](https://wirebox.ortusbooks.com) to create and manage your Couchbase Client:

```
// Map our Couchbase Client via WireBox Binder
map( "CouchbaseClient" )
    .to( "cfcouchbase.CouchbaseClient" )
    .initArg( name="config", value={} )
    .asSingleton();
```

## Shutting Down The Client

When you are finished with the client, you need to call its `shutdown()` method to close open connections to the Couchbase server. The following code sample will wait up to 10 seconds for connections to be closed.

```
public boolean function onApplicationEnd(){        
    application.couchbase.shutdown( 10 );
    return true;
}
```

> **Danger:** Each Couchbase bucket operates independently and uses its own authentication mechanisms. You need an instance of `CouchbaseClient` for each bucket you want to interact with. It is also extremely important that you shutdown the clients whenever your application goes down in order to gracefully shutdown connections, else your server might degrade.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cfcouchbase.ortusbooks.com/installation/traditional-apps.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
