Hi Roman,
I ended up writing a little custom cache provider and cache implementation. The custom cache is just a hack of the code at com.googlecode.hibernate.memcached.MemcachedCache so you should grab that from github.
I wanted to use the same memcached client that is in use throughout the rest of the application so my hacked version of the cache impl looks like this:
--------------------------------
public class HibernateCache implements org.hibernate.cache.Cache{
.
.
private play.cache.CacheImpl cache;
.
.
//Begin constructor
public HibernateCache(String regionName) {
.
.
this.cache = MemcachedImpl.getInstance();
.
.
}
//end constructor
//the rest isn't much different than the original
-------------------------------------
For the custom cache provider I just have this:
---------------------------------------------------------
public class HibernateCacheProvider implements org.hibernate.cache.CacheProvider{
private final String region = "default";
private HibernateCache cache;
public HibernateCacheProvider(){
cache = new HibernateCache(region);
}
public Cache buildCache(String regionName, Properties properties)
throws CacheException {
return new HibernateCache(region);
}
public boolean isMinimalPutsEnabledByDefault() {
return true;
}
public long nextTimestamp() {
return cache.nextTimestamp();
}
public void start(Properties arg0) throws CacheException {
}
public void stop() {
}
public String toString() {
return "play";
}
}
----------------------------------------------------
My config looks like this:
----------------------------------------------------
hibernate.cache.provider_class=cache.HibernateCacheProvider
hibernate.cache.use_query_cache=true
hibernate.cache.use_second_level_cache=true
hibernate.memcached.cacheTimeSeconds=300
hibernate.memcached.connectionFactory=BinaryConnectionFactory
------------------------------------------
This works very well but will only work until about hibernate 3.6 so we are using it with play 1.2.4 and do not
expect to be able to use it if we move to play 1.3.x.
Hope this helps.
Joel