@@ -16,21 +16,21 @@ Add a dependency on one of the three artifacts produced by the project. The choi
1616
1717
1818* Cache: ** cloudant-client-cache** . Provides all the cache interfaces and utility functions as well
19- as a very simple LRU ` Cache ` implementation.
19+ as a very simple LRU ` com.cloudant.client.cache. Cache` implementation.
2020``` groovy
2121dependencies {
2222 compile group: 'com.cloudant', name: 'cloudant-client-cache', version: 'latest.release'
2323}
2424```
2525* In-process cache: ** cloudant-client-cache-in-process** (depends on cloudant-client-cache). Provides a
26- ` CacheWithLifetimes ` implementation that runs in-process.
26+ ` com.cloudant.client.cache. CacheWithLifetimes` implementation that runs in-process.
2727``` groovy
2828dependencies {
2929 compile group: 'com.cloudant', name: 'cloudant-client-cache-in-process', version: 'latest.release'
3030}
3131```
3232* Redis cache: ** cloudant-client-cache-redis** (depends on cloudant-client-cache). Provides a
33- ` CacheWithLifetimes ` implementation that uses a Redis instance as the store.
33+ ` com.cloudant.client.cache. CacheWithLifetimes` implementation that uses a Redis instance as the store.
3434``` groovy
3535dependencies {
3636 compile group: 'com.cloudant', name: 'cloudant-client-cache-redis', version: 'latest.release'
@@ -39,32 +39,35 @@ dependencies {
3939
4040### Instantiate a cache
4141
42- * ` LRUCache ` :
42+ * ` com.cloudant.client.cache. LRUCache` :
4343``` java
4444// Example with a maximum capacity of 100 objects
4545Cache<String , Object > cache = new LRUCache<> (100 );
4646```
47- * ` InProcessCache ` :
47+ * ` com.cloudant.client.cache.inprocess. InProcessCache` :
4848``` java
4949// Example with up to 100 objects with a default 1 minute lifetime:
5050CacheWithLifetimes<String , Object > cache = new InProcessCache<> (100 , 60000 );
5151```
52- * ` RedisCache ` :
52+ * ` com.cloudant.client.cache.redis. RedisCache` :
5353``` java
5454// Example with a default 1 minute lifetime, connected to a local Redis instance:
5555CacheWithLifetimes<String , Object > cache = new RedisCache<> (" localhost" , 60000 );
5656```
5757
58- ### Configure the cache with your ` Database ` instance
58+ ### Configure the cache with your ` com.cloudant.client.api.Database ` instance
59+
60+ The ` com.cloudant.client.cache.DatabaseCache ` and
61+ ` com.cloudant.client.cache.DatabaseCacheWithLifetimes ` classes extend the
62+ java-cloudant ` com.cloudant.client.api.Database ` so an existing application can
63+ add cache functionality with minimal code changes.
5964
6065``` java
6166// Get the Cloudant client instance and database object.
6267CloudantClient client = ClientBuilder . account(" example" ). build();
6368Database db = client. database(" example-database" , false );
6469
6570// Create a new DatabaseCache with the database and cache instances.
66- // The `DatabaseCache` and `DatabaseCacheWithLifetimes` classes implement the java-cloudant Database
67- // interface so an existing application can add a local cache with minimal code changes.
6871Database cachedDb = new DatabaseCache (db, cache);
6972// Use this cachedDb instance in place of your normal db instance to utilise the cache.
7073// Keep references to both instances to switch between cached and un-cached access to the database.
0 commit comments