Skip to content

Commit a88b3ab

Browse files
ddlathamraykrueger
authored andcommitted
enable config support for daemon mode in spy memcached client factory
also fixed a couple generics warnings
1 parent 99e948f commit a88b3ab

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

‎src/main/java/com/googlecode/hibernate/memcached/MemcachedCache.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public long getElementCountOnDisk() {
223223
return -1;
224224
}
225225

226-
public Map toMap() {
226+
public Map<?,?> toMap() {
227227
throw new UnsupportedOperationException();
228228
}
229229

‎src/main/java/com/googlecode/hibernate/memcached/MemcachedCacheProvider.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public void start(Properties properties) throws CacheException {
160160
protected MemcacheClientFactory getMemcachedClientFactory(Config config) {
161161
String factoryClassName = config.getMemcachedClientFactoryName();
162162

163-
Constructor constructor;
163+
Constructor<?> constructor;
164164
try {
165165
constructor = Class.forName(factoryClassName)
166166
.getConstructor(PropertiesHelper.class);

‎src/main/java/com/googlecode/hibernate/memcached/spymemcached/SpyMemcacheClientFactory.java‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class SpyMemcacheClientFactory implements MemcacheClientFactory {
2020
public static final String PROP_OPERATION_TIMEOUT = Config.PROP_PREFIX + "operationTimeout";
2121
public static final String PROP_HASH_ALGORITHM = Config.PROP_PREFIX + "hashAlgorithm";
2222
public static final String PROP_CONNECTION_FACTORY = Config.PROP_PREFIX + "connectionFactory";
23+
public static final String PROP_DAEMON_MODE = Config.PROP_PREFIX + "daemonMode";
2324
private final PropertiesHelper properties;
2425

2526
public SpyMemcacheClientFactory(PropertiesHelper properties) {
@@ -61,6 +62,11 @@ private DefaultConnectionFactory buildDefaultConnectionFactory() {
6162
public long getOperationTimeout() {
6263
return getOperationTimeoutMillis();
6364
}
65+
66+
@Override
67+
public boolean isDaemon() {
68+
return isDaemonMode();
69+
}
6470
};
6571
}
6672

@@ -70,6 +76,11 @@ private KetamaConnectionFactory buildKetamaConnectionFactory() {
7076
public long getOperationTimeout() {
7177
return getOperationTimeoutMillis();
7278
}
79+
80+
@Override
81+
public boolean isDaemon() {
82+
return isDaemonMode();
83+
}
7384
};
7485
}
7586

@@ -79,6 +90,11 @@ private BinaryConnectionFactory buildBinaryConnectionFactory() {
7990
public long getOperationTimeout() {
8091
return getOperationTimeoutMillis();
8192
}
93+
94+
@Override
95+
public boolean isDaemon() {
96+
return isDaemonMode();
97+
}
8298
};
8399
}
84100

@@ -101,6 +117,10 @@ public long getOperationTimeoutMillis() {
101117
DefaultConnectionFactory.DEFAULT_OPERATION_TIMEOUT);
102118
}
103119

120+
public boolean isDaemonMode() {
121+
return properties.getBoolean(PROP_DAEMON_MODE, false);
122+
}
123+
104124
public HashAlgorithm getHashAlgorithm() {
105125
return properties.getEnum(PROP_HASH_ALGORITHM,
106126
HashAlgorithm.class,

‎src/test/groovy/com/googlecode/hibernate/memcached/spymemcached/SpyMemcacheClientFactoryTest.groovy‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ class SpyMemcacheClientFactoryTest extends BaseTestCase {
2525
properties.setProperty "hibernate.memcached.operationQueueLength", "8192"
2626
properties.setProperty "hibernate.memcached.readBufferLength", "8192"
2727
properties.setProperty "hibernate.memcached.operationTimeout", "5000"
28+
properties.setProperty "hibernate.memcached.daemonMode", "true"
2829

29-
SpyMemcacheClientFactory factory = new SpyMemcacheClientFactory(new PropertiesHelper(new Properties()))
30+
SpyMemcacheClientFactory factory = new SpyMemcacheClientFactory(new PropertiesHelper(properties))
3031
client = factory.createMemcacheClient()
3132
assert client
3233
}

0 commit comments

Comments
 (0)