marcuspocus / hazelcast

Hazelcast is a dropin replacement for the Play! Framework cache. Hazelcast provide also some other services like Clustered Executors, Maps, AtomicNumbers, Topics, Queues, etc...
http://www.playframework.com/modules/hazelcast
22 stars 9 forks source link

h1. Documentation for the Hazelcast module

bq. This module is a @dropin@ replacement for EhCacheImpl or MemcachedImpl from Play. It allow your application to have a clustered cache when you can't install a memcached server on your platform. It's also a great free open source In-Memory Data Grid

See "Hazelcast Documentation":http://www.hazelcast.com/documentation.jsp for more details.

h2. Installing Hazelcast Module

p. To install Hazelcast Plugin module, you do like every other Play Modules:

bc. play install hazelcast[-version]

h2. Using Hazelcast Module in your application (Dependency management)

h3. There is two way to use the module

bc. module.hazelcast=${play.path}/modules/hazelcast-[version]

bc.. require:

h3. Parameters

You can disable the module in your application by usinga parameter in @application.conf@:

bc. hazelcast.disabled=true

The value defaults to false.

bc. hazelcast.configFile=conf/hazelcast-dev.xml

You can specify the configuration file to be used. The value defaults to conf/hazelcast.xml

h2. Using standard Play! Framework Cache Mechanisms

p. All the standard Play annotations or methods work seamlessly with Hazelcast instead of EhCache or Memcached.

bq. See "Play Framework Cache Documentation":/@documentation/cache for @CacheFor("1h")@ and provided Play! @Cache.xxx()@ usage.

h2. Using features from Hazelcast

h3. Using @Inject to inject an instance of Hazelcast in your controller

bc(Java). @Inject private static HazelcastInstance hazel;

h3. Injecting the default ExecutorService

bc(Java). @Inject private static ExecutorService executor;

h3. Using @Named to inject a named resource

bc(Java). @Named("MyQueue") private static Queue myQueue;

h2. Hazelcast clustered services

h3. Configuration file hazelcast.xml

You can modify hazelcast.xml to your need to create more Queues or Map and modify the default ExecutorService parameters. Just copy the hazelcast.xml file from the module conf directory to your application conf directory. This is also the file that allow you to change from multicast to TCPIP static cluster definition.

h3. Hazelcast Object type that can be retreived via @@Named@ annotation

h3. Hazelcast Object type that can by retreived via @@Inject@ annotation

h3. Method directly accessible on @HazelcastPlugin@ class

fn1. Use this to get a Transaction object then you can @begin()@ or @commit()@ or @rollback()@ operations on cluster.

fn2. Use this to lock an object across the cluster.

fn3. Use this if you absolutely NEED to directly get the Default Hazelcast instance.

h2. Hibernate second level cache configuration

h2. Roadmap

p. I'd like to see some basic Play! features use Hazel capabilities: