This repository has been archived by the owner on Dec 1, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Md5KeyStrategy and Sha1KeyStrategy now both work independently of the HashCodeKeyStrategy. StringKeyStrategy and HashCodeKeyStrategy will now both throw exceptions if the key is too long, no more auto truncated for people doing bad things.
- Loading branch information
1 parent
67dcd2a
commit 70881ae
Showing
9 changed files
with
54 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/com/googlecode/hibernate/memcached/DigestKeyStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.googlecode.hibernate.memcached; | ||
|
||
import com.googlecode.hibernate.memcached.utils.StringUtils; | ||
|
||
/** | ||
* @author Ray Krueger | ||
*/ | ||
public abstract class DigestKeyStrategy extends AbstractKeyStrategy { | ||
|
||
protected String transformKeyObject(Object key) { | ||
return key.toString() + ":" + key.hashCode(); | ||
} | ||
|
||
protected String concatenateKey(String regionName, long clearIndex, Object key) { | ||
String longKey = super.concatenateKey(regionName, clearIndex, key); | ||
return digest(longKey); | ||
} | ||
|
||
protected abstract String digest(String string); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,4 @@ abstract class AbstractKeyStrategyTestCase extends BaseTestCase { | |
|
||
abstract KeyStrategy getKeyStrategy(); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters