Search in sources :

Example 1 with DatabaseRedisClient

use of com.publiccms.common.redis.DatabaseRedisClient in project PublicCMS-preview by sanluan.

the class RedisRegionFactory method start.

@Override
public void start(SessionFactoryOptions option, Properties properties) throws CacheException {
    log.debug("RedisRegionFactory is starting... ");
    this.options = option;
    try {
        if (redisClient == null) {
            String configurationResourceName = (String) properties.get("hibernate.redis.configurationResourceName");
            if (null != configurationResourceName) {
                Properties redisProperties = PropertiesLoaderUtils.loadAllProperties(configurationResourceName);
                this.redisClient = new DatabaseRedisClient(RedisUtils.createJedisPool(redisProperties));
            }
            this.cacheTimestamper = createCacheTimestamper(redisClient, RedisRegionFactory.class.getName());
        }
        log.info("RedisRegionFactory is started.");
    } catch (Exception e) {
        log.error("Fail to start RedisRegionFactory.", e);
        throw new CacheException(e);
    }
}
Also used : CacheException(org.hibernate.cache.CacheException) Properties(java.util.Properties) DatabaseRedisClient(com.publiccms.common.redis.DatabaseRedisClient) CacheException(org.hibernate.cache.CacheException)

Example 2 with DatabaseRedisClient

use of com.publiccms.common.redis.DatabaseRedisClient in project PublicCMS-preview by sanluan.

the class SingletonRedisRegionFactory method start.

@Override
public void start(SessionFactoryOptions option, Properties properties) throws CacheException {
    log.debug("SingletonRedisRegionFactory is starting...");
    this.options = option;
    try {
        if (redisClient == null) {
            String configurationResourceName = (String) properties.get("hibernate.redis.configurationResourceName");
            if (CommonUtils.notEmpty(configurationResourceName)) {
                Properties redisProperties = PropertiesLoaderUtils.loadAllProperties(configurationResourceName);
                this.redisClient = new DatabaseRedisClient(RedisUtils.createJedisPool(redisProperties));
            }
            this.cacheTimestamper = createCacheTimestamper(redisClient, SingletonRedisRegionFactory.class.getName());
        }
        referenceCount.incrementAndGet();
        log.info("RedisRegionFactory is started.");
    } catch (Exception e) {
        throw new CacheException(e);
    }
}
Also used : CacheException(org.hibernate.cache.CacheException) Properties(java.util.Properties) DatabaseRedisClient(com.publiccms.common.redis.DatabaseRedisClient) CacheException(org.hibernate.cache.CacheException)

Aggregations

DatabaseRedisClient (com.publiccms.common.redis.DatabaseRedisClient)2 Properties (java.util.Properties)2 CacheException (org.hibernate.cache.CacheException)2