Skip to content

Commit

Permalink
add separate property for cacheLockTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaicostin committed Jun 7, 2017
1 parent fd88842 commit 588d734
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.github.mihaicostin</groupId>
<artifactId>hibernate-l2-memcached</artifactId>
<version>1.1.0</version>
<version>4.3.11.0</version>
<name>hibernate-l2-memcached</name>
<description>A library for using Memcached as a second level distributed cache in Hibernate.</description>
<url>https://github.com/mihaicostin/hibernate-l2-memcached</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ public long nextTimestamp() {
}

public EntityRegion buildEntityRegion(String regionName, Properties properties, CacheDataDescription metadata) throws CacheException {
return new MemcachedEntityRegion(getCache(regionName), settings,
metadata, properties, client);
return new MemcachedEntityRegion(getCache(regionName), settings, metadata, properties, client);
}

public NaturalIdRegion buildNaturalIdRegion(String regionName, Properties properties, CacheDataDescription metadata) throws CacheException {
Expand All @@ -96,11 +95,11 @@ public CollectionRegion buildCollectionRegion(String regionName, Properties prop
}

public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) throws CacheException {
return new MemcachedQueryResultsRegion(getCache(regionName));
return new MemcachedQueryResultsRegion(getCache(regionName), properties);
}

public TimestampsRegion buildTimestampsRegion(String regionName, Properties properties) throws CacheException {
return new MemcachedTimestampsRegion(getCache(regionName));
return new MemcachedTimestampsRegion(getCache(regionName), properties);
}

protected MemcacheClientFactory getMemcachedClientFactory(Config config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@

import java.util.Collections;
import java.util.Map;
import java.util.Properties;

public abstract class AbstractMemcachedRegion implements Region {

private static final int DEFAULT_CACHE_LOCK_TIMEOUT = 60000;
private final int lockTimeout;

protected MemcachedCache cache;

AbstractMemcachedRegion(MemcachedCache cache) {
AbstractMemcachedRegion(MemcachedCache cache, Properties properties) {
this.cache = cache;
String property = properties.getProperty("hibernate.memcached.cacheLockTimeout", String.valueOf(DEFAULT_CACHE_LOCK_TIMEOUT));
this.lockTimeout = Integer.decode(property);
}

public String getName() {
Expand Down Expand Up @@ -73,7 +79,7 @@ public long nextTimestamp() {
* @return timeout in ms
*/
public int getTimeout() {
return cache.getTimeoutSeconds() * 1000;
return lockTimeout;
}

public MemcachedCache getCache() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class MemcachedCollectionRegion extends AbstractMemcachedRegion implement
private final Settings settings;

public MemcachedCollectionRegion(MemcachedCache cache, Settings settings, CacheDataDescription metadata, Properties properties, Memcache client) {
super(cache);
super(cache, properties);
this.metadata = metadata;
this.settings = settings;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class MemcachedEntityRegion extends AbstractMemcachedRegion implements En
private final Settings settings;

public MemcachedEntityRegion(MemcachedCache cache, Settings settings, CacheDataDescription metadata, Properties properties, Memcache client) {
super(cache);
super(cache, properties);
this.metadata = metadata;
this.settings = settings;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class MemcachedNaturalIdRegion extends AbstractMemcachedRegion implements
private final Settings settings;

public MemcachedNaturalIdRegion(MemcachedCache cache, Settings settings, CacheDataDescription metadata, Properties properties, Memcache client) {
super(cache);
super(cache, properties);
this.metadata = metadata;
this.settings = settings;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@

import com.mc.hibernate.memcached.MemcachedCache;

import java.util.Properties;

public class MemcachedQueryResultsRegion extends AbstractMemcachedRegion implements QueryResultsRegion {

private final Logger log = LoggerFactory.getLogger(MemcachedQueryResultsRegion.class);

public MemcachedQueryResultsRegion(MemcachedCache cache) {
super(cache);
public MemcachedQueryResultsRegion(MemcachedCache cache, Properties properties) {
super(cache, properties);
}

public Object get(Object key) throws CacheException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@

import com.mc.hibernate.memcached.MemcachedCache;

import java.util.Properties;

public class MemcachedTimestampsRegion extends AbstractMemcachedRegion implements TimestampsRegion {

private final Logger log = LoggerFactory.getLogger(MemcachedTimestampsRegion.class);

public MemcachedTimestampsRegion(MemcachedCache cache) {
super(cache);
public MemcachedTimestampsRegion(MemcachedCache cache, Properties properties) {
super(cache, properties);
}

public Object get(Object key) throws CacheException {
Expand Down

0 comments on commit 588d734

Please sign in to comment.