As Couchbase continues to experience growth as a company and increased adoption by the open source community we continue to encounter new challenges and use cases along the way. Many enterprises are turning to us to help add a cache to an existing application or evolve applications to next generation technologies. For these level two cache implementations we’ve helped develop a data access layer for applications in the Spring project. Spring Data Couchbase provides integration with the Couchbase Server cluster by providing POJO centric data interaction with Couchbase Buckets and helping to provide a repository-style implementation. This effort has been very successful and has generated a lot of interest.

However, there’s more to the story a simple web search for “JPA” uncovers that helps us understand additional needs across the enterprise. While the JPA standard is well defined ultimately each vendor implementation varies enough that supporting specific ORM’s like Eclipselink and Hibernate would require additional work. We engaged our partners at Thumbtack Technology who deployed one of their expert NOSQL development teams to help get the job done. 

The objective was to provide a framework of boilerplate code to leverage Couchbase as a level two cache for both Eclipselink and Hibernate. There are improvements coming with the release of our 2.0 SDK’s and additional integration improvements but we wanted to be able to support these caching efforts in the near term. Bothe the Hibernate and Eclipselink JPA connectors have been published by Thumbtack on github with test cases to show the configuration.

Hibernate – https://github.com/thumbtack-technology/Couchbase-L2-Hibernate
EclipseLink – https://github.com/thumbtack-technology/Couchbase-L2-EclipseLink

While there is always the ability to leverage Moxi to enable existing memcached clients to be vbubket aware. We knew the javax.persistance package had a cache interface available but each vendor implementation requires nuances that need to be addressed. For example, in reviewing the the associated eclipselink documentation shows the ability to add a level 2 cache but nothing that helps us understand the specifics of leveraging a NoSQL solution. Thumbtack helped us solve these configuration challenges.

Eclipselink persistence.xml
<property name=“couchbase.cache.servers”
         value=“http://couchbase-cluster-node01:8091/pools,
                http://couchbase-cluster-node02:8091/pools”/>

<property name=“couchbase.cache.bucket.name” value=“l2-cache”/>
<property name=“couchbase.cache.bucket.password” value=“cachepwd”/>
<property name=“couchbase.cache.ttl” value=“600”/>

<property name=“eclipselink.descriptor.customizer.
value=”net.thumbtack.couchbase.eclipselink.ClassCustomizer”/>
>
<property name=“eclipselink.descriptor.customizer.Order”
             value=“net.thumbtack.couchbase.eclipselink.ClassCustomizer”/>

>
<property name=“eclipselink.descriptor.customizer.
value=”net.thumbtack.couchbase.eclipselink.ClassCustomizer”/>

Hibernate persistence.xml
<property name=“couchbase.cache.servers”
         value=“http://couchbase-cluster-node01:8091/pools,
                http://couchbase-cluster-node02:8091/pools”/>

<property name=“couchbase.cache.bucket.name” value=“l2-cache”/>
<property name=“couchbase.cache.bucket.password” value=“cachepwd”/>
<property name=“couchbase.cache.ttl” value=“600”/>

<property name=“hibernate.cache.region.factory_class” value=“com.googlecode.hibernate.memcached.MemcachedRegionFactory” />
<property name=“hibernate.memcached.memcacheClientFactory” value=“net.thumbtack.hibernate.couchbase.CouchbaseClientFactory” />

Additional details in getting the Thumbtack test cases running locally can be found in the github repositories.

These connectors provide us the ability to extend existing applications by adding an object cache with a durable cluster. By leveraging the power of Couchbase we can prevent Cold Cache, dramatically reduce load on your RDBMS, auto-shard across the cluster and provide a durable object store.

Author

Posted by The Couchbase Team

Jennifer Garcia is a Senior Web Manager at Couchbase Inc. As the website manager, Jennifer has overall responsibility for the website properties including design, implementation, content, and performance.

Leave a reply