Skip to content

Commit 3d4828c

Browse files
committed
Ensure Sha1KeyStrategy is the default.
Missed that HashCodeKeyStrategy was initialized as the default with in the MemcachedCache instance.
1 parent 5c21f5b commit 3d4828c

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
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
@@ -54,7 +54,7 @@ public class MemcachedCache implements Cache {
5454
private final String clearIndexKey;
5555
private int cacheTimeSeconds = 300;
5656
private boolean clearSupported = false;
57-
private KeyStrategy keyStrategy = new HashCodeKeyStrategy();
57+
private KeyStrategy keyStrategy = new Sha1KeyStrategy();
5858
private boolean dogpilePreventionEnabled = false;
5959
private double dogpilePreventionExpirationFactor = 2;
6060

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* <td>Space delimited list of memcached instances in host:port format</td></tr>
3838
* <tr><td>hibernate.memcached.cacheTimeSeconds</td><td>300</td>
3939
* <td>The default number of seconds items should be cached. Can be overriden at the regon level.</td></tr>
40-
* <tr><td>hibernate.memcached.keyStrategy</td><td>{@link HashCodeKeyStrategy}</td>
40+
* <tr><td>hibernate.memcached.keyStrategy</td><td>{@link Sha1KeyStrategy}</td>
4141
* <td>Sets the strategy class to to use for generating cache keys.
4242
* Must provide a class name that implements {@link com.googlecode.hibernate.memcached.KeyStrategy}</td></tr>
4343
* <tr><td>hibernate.memcached.readBufferSize</td>
@@ -199,4 +199,4 @@ public void stop() {
199199
public boolean isMinimalPutsEnabledByDefault() {
200200
return true;
201201
}
202-
}
202+
}

‎src/test/groovy/com/googlecode/hibernate/memcached/MemcachedCacheTest.groovy‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class MemcachedCacheTest extends BaseTestCase {
2525
void test_dogpile_cache_miss() {
2626
MockMemcached mockCache = new MockMemcached()
2727
cache = new MemcachedCache("region", mockCache)
28+
cache.setKeyStrategy(new HashCodeKeyStrategy());
2829
cache.dogpilePreventionEnabled = true
2930
cache.cacheTimeSeconds = 1
3031
cache.dogpilePreventionExpirationFactor = 2
@@ -39,6 +40,7 @@ class MemcachedCacheTest extends BaseTestCase {
3940
void test_dogpile_cache_hit() {
4041
MockMemcached mockCache = new MockMemcached()
4142
cache = new MemcachedCache("region", mockCache)
43+
cache.setKeyStrategy(new HashCodeKeyStrategy());
4244
cache.dogpilePreventionEnabled = true
4345
cache.cacheTimeSeconds = 1
4446
cache.dogpilePreventionExpirationFactor = 2
@@ -48,4 +50,4 @@ class MemcachedCacheTest extends BaseTestCase {
4850
assertEquals MemcachedCache.DOGPILE_TOKEN, mockCache.cache["region:0:3556498.dogpileTokenKey"]
4951
}
5052

51-
}
53+
}

0 commit comments

Comments
 (0)