Redis can be enabled from nuxeo.conf:
nuxeo.redis.enabled=true
nuxeo.redis.host=localhost (this is the default)
nuxeo.redis.port=6379 (this is the default)
Also available are (with defaults):
nuxeo.redis.prefix=nuxeo:work:
nuxeo.redis.password=
nuxeo.redis.database=0
nuxeo.redis.timeout=2000
This automatically activates the Redis-based WorkManage queuing, unless the nuxeo.conf property nuxeo.work.queuing is not set to redis.
To configure Redis manually, this extension point can be used:
<extension target="org.nuxeo.ecm.core.redis.RedisService" point="configuration">
<redis disabled="false">
<prefix>nuxeo:work:</prefix>
<host>localhost</host>
<port>6379</port>
<password>secret</password>
<database>0</database>
<timeout>2000</timeout>
</redis>
</extension>
To use the Redis service, do:
RedisService redisService = Framework.getLocalService(RedisService.class);
This service currently provides two methods:
redisService.getJedisPool();
redisService.getPrefix(); // should be used as prefix for any key
Standard usage pattern is:
protected Jedis getJedis()
{
return redisService.getJedisPool().getResource();
}
protected void closeJedis(Jedis jedis)
{
redisService.getJedisPool().returnResource(jedis);
}
protected void myMethod() throws IOException {
Jedis jedis = getJedis();
try
{
// ... use jedis here ...
// ... all keys should be prefixed with redisService.getPrefix()
}
finally
{
closeJedis(jedis);
}
}