org.redisson.hibernate.RedissonRegionFactory Java Examples

The following examples show how to use org.redisson.hibernate.RedissonRegionFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseRegion.java    From redisson with Apache License 2.0 6 votes vote down vote up
public BaseRegion(RMapCache<Object, Object> mapCache, ConnectionManager connectionManager, RegionFactory regionFactory, CacheDataDescription metadata, Properties properties, String defaultKey) {
    super();
    this.mapCache = mapCache;
    this.regionFactory = regionFactory;
    this.metadata = metadata;
    this.connectionManager = connectionManager;
    
    String maxEntries = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.MAX_ENTRIES_SUFFIX);
    if (maxEntries != null) {
        mapCache.setMaxSize(Integer.valueOf(maxEntries));
    }
    String timeToLive = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.TTL_SUFFIX);
    if (timeToLive != null) {
        ttl = Integer.valueOf(timeToLive);
    }
    String maxIdleTime = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.MAX_IDLE_SUFFIX);
    if (maxIdleTime != null) {
        maxIdle = Integer.valueOf(maxIdleTime);
    }

    String fallbackValue = (String) properties.getOrDefault(RedissonRegionFactory.FALLBACK, "false");
    fallback = Boolean.valueOf(fallbackValue);
}
 
Example #2
Source File: ReadWriteTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure(Configuration cfg) {
    super.configure(cfg);
    cfg.setProperty(Environment.DRIVER, org.h2.Driver.class.getName());
    cfg.setProperty(Environment.URL, "jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1");
    cfg.setProperty(Environment.USER, "sa");
    cfg.setProperty(Environment.PASS, "");
    cfg.setProperty(Environment.CACHE_REGION_PREFIX, "");
    cfg.setProperty(Environment.GENERATE_STATISTICS, "true");

    cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
    cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
    cfg.setProperty(Environment.CACHE_REGION_FACTORY, RedissonRegionFactory.class.getName());
    
    cfg.setProperty("hibernate.cache.redisson.item.eviction.max_entries", "100");
    cfg.setProperty("hibernate.cache.redisson.item.expiration.time_to_live", "1500");
    cfg.setProperty("hibernate.cache.redisson.item.expiration.max_idle_time", "1000");
}
 
Example #3
Source File: BaseRegion.java    From redisson with Apache License 2.0 6 votes vote down vote up
public BaseRegion(RMapCache<Object, Object> mapCache, ConnectionManager connectionManager, RegionFactory regionFactory, CacheDataDescription metadata, Properties properties, String defaultKey) {
    super();
    this.mapCache = mapCache;
    this.regionFactory = regionFactory;
    this.metadata = metadata;
    this.connectionManager = connectionManager;
    
    String maxEntries = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.MAX_ENTRIES_SUFFIX);
    if (maxEntries != null) {
        mapCache.setMaxSize(Integer.valueOf(maxEntries));
    }
    String timeToLive = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.TTL_SUFFIX);
    if (timeToLive != null) {
        ttl = Integer.valueOf(timeToLive);
    }
    String maxIdleTime = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.MAX_IDLE_SUFFIX);
    if (maxIdleTime != null) {
        maxIdle = Integer.valueOf(maxIdleTime);
    }

    String fallbackValue = (String) properties.getOrDefault(RedissonRegionFactory.FALLBACK, "false");
    fallback = Boolean.valueOf(fallbackValue);
}
 
Example #4
Source File: ReadWriteTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure(Configuration cfg) {
    super.configure(cfg);
    cfg.setProperty(Environment.DRIVER, org.h2.Driver.class.getName());
    cfg.setProperty(Environment.URL, "jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;");
    cfg.setProperty(Environment.USER, "sa");
    cfg.setProperty(Environment.PASS, "");
    cfg.setProperty(Environment.CACHE_REGION_PREFIX, "");
    cfg.setProperty(Environment.GENERATE_STATISTICS, "true");

    cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
    cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
    cfg.setProperty(Environment.CACHE_REGION_FACTORY, RedissonRegionFactory.class.getName());
    
    cfg.setProperty("hibernate.cache.redisson.item.eviction.max_entries", "100");
    cfg.setProperty("hibernate.cache.redisson.item.expiration.time_to_live", "1500");
    cfg.setProperty("hibernate.cache.redisson.item.expiration.max_idle_time", "1000");
    
    cfg.setProperty("hibernate.cache.redisson.item##NaturalId.eviction.max_entries", "1000");
    cfg.setProperty("hibernate.cache.redisson.item##NaturalId.expiration.time_to_live", "1100");
    cfg.setProperty("hibernate.cache.redisson.item##NaturalId.expiration.max_idle_time", "1200");
}
 
Example #5
Source File: ReadWriteTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure(Configuration cfg) {
    super.configure(cfg);
    cfg.setProperty(Environment.DRIVER, org.h2.Driver.class.getName());
    cfg.setProperty(Environment.URL, "jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;");
    cfg.setProperty(Environment.USER, "sa");
    cfg.setProperty(Environment.PASS, "");
    cfg.setProperty(Environment.CACHE_REGION_PREFIX, "");
    cfg.setProperty(Environment.GENERATE_STATISTICS, "true");

    cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
    cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
    cfg.setProperty(Environment.CACHE_REGION_FACTORY, RedissonRegionFactory.class.getName());
    
    cfg.setProperty("hibernate.cache.redisson.item.eviction.max_entries", "100");
    cfg.setProperty("hibernate.cache.redisson.item.expiration.time_to_live", "1500");
    cfg.setProperty("hibernate.cache.redisson.item.expiration.max_idle_time", "1000");
}
 
Example #6
Source File: BaseRegion.java    From redisson with Apache License 2.0 6 votes vote down vote up
public BaseRegion(RMapCache<Object, Object> mapCache, ConnectionManager connectionManager, RegionFactory regionFactory, CacheDataDescription metadata, Properties properties, String defaultKey) {
    super();
    this.mapCache = mapCache;
    this.regionFactory = regionFactory;
    this.metadata = metadata;
    this.connectionManager = connectionManager;
    
    String maxEntries = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.MAX_ENTRIES_SUFFIX);
    if (maxEntries != null) {
        mapCache.setMaxSize(Integer.valueOf(maxEntries));
    }
    String timeToLive = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.TTL_SUFFIX);
    if (timeToLive != null) {
        ttl = Integer.valueOf(timeToLive);
    }
    String maxIdleTime = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.MAX_IDLE_SUFFIX);
    if (maxIdleTime != null) {
        maxIdle = Integer.valueOf(maxIdleTime);
    }

    String fallbackValue = (String) properties.getOrDefault(RedissonRegionFactory.FALLBACK, "false");
    fallback = Boolean.valueOf(fallbackValue);
}
 
Example #7
Source File: ReadWriteTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure(Configuration cfg) {
    super.configure(cfg);
    cfg.setProperty(Environment.DRIVER, org.h2.Driver.class.getName());
    cfg.setProperty(Environment.URL, "jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;");
    cfg.setProperty(Environment.USER, "sa");
    cfg.setProperty(Environment.PASS, "");
    cfg.setProperty(Environment.CACHE_REGION_PREFIX, "");
    cfg.setProperty(Environment.GENERATE_STATISTICS, "true");

    cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
    cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
    cfg.setProperty(Environment.CACHE_REGION_FACTORY, RedissonRegionFactory.class.getName());
    
    cfg.setProperty("hibernate.cache.redisson.item.eviction.max_entries", "100");
    cfg.setProperty("hibernate.cache.redisson.item.expiration.time_to_live", "1500");
    cfg.setProperty("hibernate.cache.redisson.item.expiration.max_idle_time", "1000");
}
 
Example #8
Source File: BaseRegion.java    From redisson with Apache License 2.0 5 votes vote down vote up
private String getProperty(Properties properties, String name, String defaultKey, String suffix) {
    String value = properties.getProperty(RedissonRegionFactory.CONFIG_PREFIX + name + suffix);
    if (value != null) {
        return value;
    }
    String defValue = properties.getProperty(RedissonRegionFactory.CONFIG_PREFIX + defaultKey + suffix);
    if (defValue != null) {
        return defValue;
    }
    return null;
}
 
Example #9
Source File: TransactionalTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure(Configuration cfg) {
    super.configure(cfg);
    cfg.setProperty(Environment.DRIVER, org.h2.Driver.class.getName());
    cfg.setProperty(Environment.URL, "jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1");
    cfg.setProperty(Environment.USER, "sa");
    cfg.setProperty(Environment.PASS, "");
    cfg.setProperty(Environment.CACHE_REGION_PREFIX, "");
    cfg.setProperty(Environment.GENERATE_STATISTICS, "true");

    cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
    cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
    cfg.setProperty(Environment.CACHE_REGION_FACTORY, RedissonRegionFactory.class.getName());
}
 
Example #10
Source File: BaseRegion.java    From redisson with Apache License 2.0 5 votes vote down vote up
private String getProperty(Properties properties, String name, String defaultKey, String suffix) {
    String value = properties.getProperty(RedissonRegionFactory.CONFIG_PREFIX + name + suffix);
    if (value != null) {
        return value;
    }
    String defValue = properties.getProperty(RedissonRegionFactory.CONFIG_PREFIX + defaultKey + suffix);
    if (defValue != null) {
        return defValue;
    }
    return null;
}
 
Example #11
Source File: TransactionalTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure(Configuration cfg) {
    super.configure(cfg);
    cfg.setProperty(Environment.DRIVER, org.h2.Driver.class.getName());
    cfg.setProperty(Environment.URL, "jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;");
    cfg.setProperty(Environment.USER, "sa");
    cfg.setProperty(Environment.PASS, "");
    cfg.setProperty(Environment.CACHE_REGION_PREFIX, "");
    cfg.setProperty(Environment.GENERATE_STATISTICS, "true");

    cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
    cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
    cfg.setProperty(Environment.CACHE_REGION_FACTORY, RedissonRegionFactory.class.getName());
}
 
Example #12
Source File: TransactionalTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure(Configuration cfg) {
    super.configure(cfg);
    cfg.setProperty(Environment.DRIVER, org.h2.Driver.class.getName());
    cfg.setProperty(Environment.URL, "jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;");
    cfg.setProperty(Environment.USER, "sa");
    cfg.setProperty(Environment.PASS, "");
    cfg.setProperty(Environment.CACHE_REGION_PREFIX, "");
    cfg.setProperty(Environment.GENERATE_STATISTICS, "true");

    cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
    cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
    cfg.setProperty(Environment.CACHE_REGION_FACTORY, RedissonRegionFactory.class.getName());
}
 
Example #13
Source File: BaseRegion.java    From redisson with Apache License 2.0 5 votes vote down vote up
private String getProperty(Properties properties, String name, String defaultKey, String suffix) {
    String value = properties.getProperty(RedissonRegionFactory.CONFIG_PREFIX + name + suffix);
    if (value != null) {
        return value;
    }
    String defValue = properties.getProperty(RedissonRegionFactory.CONFIG_PREFIX + defaultKey + suffix);
    if (defValue != null) {
        return defValue;
    }
    return null;
}
 
Example #14
Source File: TransactionalTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure(Configuration cfg) {
    super.configure(cfg);
    cfg.setProperty(Environment.DRIVER, org.h2.Driver.class.getName());
    cfg.setProperty(Environment.URL, "jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;");
    cfg.setProperty(Environment.USER, "sa");
    cfg.setProperty(Environment.PASS, "");
    cfg.setProperty(Environment.CACHE_REGION_PREFIX, "");
    cfg.setProperty(Environment.GENERATE_STATISTICS, "true");

    cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
    cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
    cfg.setProperty(Environment.CACHE_REGION_FACTORY, RedissonRegionFactory.class.getName());
}