Skip to content

Commit cb1029a

Browse files
committed
upgrade to 2.6.4
add storecounter with expiry add more test cases
1 parent 2c3f304 commit cb1029a

File tree

13 files changed

+327
-157
lines changed

13 files changed

+327
-157
lines changed

.classpath

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3-
<classpathentry kind="src" output="target/classes" path="src/main/java">
4-
<attributes>
5-
<attribute name="optional" value="true"/>
6-
<attribute name="maven.pomderived" value="true"/>
7-
</attributes>
8-
</classpathentry>
9-
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
10-
<attributes>
11-
<attribute name="optional" value="true"/>
12-
<attribute name="maven.pomderived" value="true"/>
13-
</attributes>
14-
</classpathentry>
15-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
16-
<attributes>
17-
<attribute name="maven.pomderived" value="true"/>
18-
</attributes>
19-
</classpathentry>
20-
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
21-
<attributes>
22-
<attribute name="maven.pomderived" value="true"/>
23-
</attributes>
24-
</classpathentry>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
4+
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
5+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
6+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
257
<classpathentry kind="output" path="target/classes"/>
268
</classpath>
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Fri Nov 25 12:08:17 CST 2011
21
eclipse.preferences.version=1
3-
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
4-
org.eclipse.jdt.core.compiler.compliance=1.5
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3+
org.eclipse.jdt.core.compiler.compliance=1.6
54
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
6-
org.eclipse.jdt.core.compiler.source=1.5
5+
org.eclipse.jdt.core.compiler.source=1.6

README

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#Author Xingen Wang ([email protected])
22
3+
Release 2.6.4:
4+
add storeCounter with expiry support.
35

46
Release 2.6.3:
57
Perhaps solve the hang issue.

build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ build.dir=classes
3333
test.build.dir=testclasses
3434
build.instr.dir=classesinstr
3535
project=java_memcached-release
36-
ver=2.6.3
36+
ver=2.6.4
3737
junit.jar=lib/junit.jar
3838
slf4japi.jar=lib/slf4j-api-1.6.1.jar
3939
slf4jsimple.jar=lib/slf4j-simple-1.6.1.jar

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.danga</groupId>
66
<artifactId>Memcached-Java-Client</artifactId>
7-
<version>2.6.3</version>
7+
<version>2.6.4</version>
88
<packaging>jar</packaging>
99

1010
<name>Memcached-Java-Client</name>
@@ -55,8 +55,8 @@
5555
<configuration>
5656
<debuglevel>none</debuglevel>
5757
<optimize>true</optimize>
58-
<source>1.5</source>
59-
<target>1.5</target>
58+
<source>1.6</source>
59+
<target>1.6</target>
6060
</configuration>
6161
</plugin>
6262
<plugin>

src/main/java/com/danga/MemCached/MemCachedClient.java

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ public boolean delete(String key) {
568568
/**
569569
* Deletes an object from cache given cache key and expiration date.
570570
*
571+
* @deprecated not supported in memcached 1.4+
571572
* @param key
572573
* the key to be removed
573574
* @param expiry
@@ -590,6 +591,7 @@ public boolean delete(String key, Date expiry) {
590591
* specified time. However, {@link #set(String, Object) set} will succeed,<br/>
591592
* and the new value will not be deleted.
592593
*
594+
* @deprecated not supported in memcached 1.4+
593595
* @param key
594596
* the key to be removed
595597
* @param hashCode
@@ -799,8 +801,8 @@ public boolean replace(String key, Object value, Date expiry, Integer hashCode)
799801
* number to store
800802
* @return true/false indicating success
801803
*/
802-
public boolean storeCounter(String key, long counter) {
803-
return storeCounter(key, new Long(counter));
804+
public boolean storeCounter(String key, Long counter) {
805+
return storeCounter(key, counter, null, null);
804806
}
805807

806808
/**
@@ -810,10 +812,29 @@ public boolean storeCounter(String key, long counter) {
810812
* cache key
811813
* @param counter
812814
* number to store
815+
* @param date
816+
* when to expire the record
813817
* @return true/false indicating success
814818
*/
815-
public boolean storeCounter(String key, Long counter) {
816-
return storeCounter(key, counter, null);
819+
public boolean storeCounter(String key, Long counter, Date date) {
820+
return storeCounter(key, counter, date, null);
821+
}
822+
823+
/**
824+
* Store a counter to memcached given a key
825+
*
826+
* @param key
827+
* cache key
828+
* @param counter
829+
* number to store
830+
* @param date
831+
* when to expire the record
832+
* @param hashCode
833+
* if not null, then the int hashcode to use
834+
* @return true/false indicating success
835+
*/
836+
public boolean storeCounter(String key, Long counter, Date date, Integer hashCode) {
837+
return set(key, counter, date, hashCode);
817838
}
818839

819840
/**
@@ -828,7 +849,7 @@ public boolean storeCounter(String key, Long counter) {
828849
* @return true/false indicating success
829850
*/
830851
public boolean storeCounter(String key, Long counter, Integer hashCode) {
831-
return set(key, counter, hashCode);
852+
return storeCounter(key, counter, null, hashCode);
832853
}
833854

834855
/**
@@ -955,7 +976,9 @@ public long addOrDecr(String key, long inc, Integer hashCode) {
955976
}
956977

957978
/**
958-
* Increment the value at the specified key by 1, and then return it.
979+
* Increment the value at the specified key by 1, and then return it.<br>
980+
* Please make sure setPrimitiveAsString=true if the key/value pair is
981+
* stored with set command.
959982
*
960983
* @param key
961984
* key where the data is stored
@@ -967,7 +990,9 @@ public long incr(String key) {
967990
}
968991

969992
/**
970-
* Increment the value at the specified key by passed in val.
993+
* Increment the value at the specified key by passed in val.<br>
994+
* Please make sure setPrimitiveAsString=true if the key/value pair is
995+
* stored with set command.
971996
*
972997
* @param key
973998
* key where the data is stored
@@ -982,7 +1007,9 @@ public long incr(String key, long inc) {
9821007

9831008
/**
9841009
* Increment the value at the specified key by the specified increment, and
985-
* then return it.
1010+
* then return it.<br>
1011+
* Please make sure setPrimitiveAsString=true if the key/value pair is
1012+
* stored with set command.
9861013
*
9871014
* @param key
9881015
* key where the data is stored
@@ -998,7 +1025,9 @@ public long incr(String key, long inc, Integer hashCode) {
9981025
}
9991026

10001027
/**
1001-
* Decrement the value at the specified key by 1, and then return it.
1028+
* Decrement the value at the specified key by 1, and then return it.<br>
1029+
* Please make sure setPrimitiveAsString=true if the key/value pair is
1030+
* stored with set command.
10021031
*
10031032
* @param key
10041033
* key where the data is stored
@@ -1011,7 +1040,9 @@ public long decr(String key) {
10111040

10121041
/**
10131042
* Decrement the value at the specified key by passed in value, and then
1014-
* return it.
1043+
* return it.<br>
1044+
* Please make sure setPrimitiveAsString=true if the key/value pair is
1045+
* stored with set command.
10151046
*
10161047
* @param key
10171048
* key where the data is stored
@@ -1026,7 +1057,9 @@ public long decr(String key, long inc) {
10261057

10271058
/**
10281059
* Decrement the value at the specified key by the specified increment, and
1029-
* then return it.
1060+
* then return it.<br>
1061+
* Please make sure setPrimitiveAsString=true if the key/value pair is
1062+
* stored with set command.
10301063
*
10311064
* @param key
10321065
* key where the data is stored

src/main/java/com/schooner/MemCached/AscIIClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ private long incrdecr(String cmdname, String key, long inc, Integer hashCode) {
582582
// Sucessfully increase.
583583
// return sock to pool and return result
584584
return Long.parseLong(line);
585-
} else if (NOTFOUND.equals(line)) {
585+
} else if (NOTFOUND.equals(line + "\r\n")) {
586586
if (log.isInfoEnabled())
587587
log.info(new StringBuffer().append("++++ key not found to incr/decr for key: ").append(key)
588588
.toString());
@@ -1630,7 +1630,7 @@ public void readResponse(SelectionKey key) throws IOException {
16301630
public boolean sync(String key, Integer hashCode) {
16311631
if (key == null) {
16321632
if (log.isErrorEnabled())
1633-
log.error("null value for key passed to delete()");
1633+
log.error("null value for key passed to sync()");
16341634
return false;
16351635
}
16361636

src/main/java/com/schooner/MemCached/SchoonerSockIOPool.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@
105105
* static {
106106
* String[] serverlist = { &quot;cache0.server.com:12345&quot;, &quot;cache1.server.com:12345&quot; };
107107
* Integer[] weights = { new Integer(5), new Integer(2) };
108-
* pool.setInitConn(500);
109-
* pool.setMinConn(50);
110-
* pool.setMaxConn(50000);
108+
* pool.setInitConn(5);
109+
* pool.setMinConn(5);
110+
* pool.setMaxConn(10);
111111
* pool.setMaintSleep(0);
112112
* pool.setNagle(false);
113113
* pool.initialize();

src/test/java/com/danga/MemCached/test/UnitTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public static void test14() {
143143
log.error("+ store/retrieve test passed");
144144

145145
assert !mc.keyExists("counterTest123");
146-
mc.storeCounter("counterTest123", 0);
146+
mc.storeCounter("counterTest123", 0L);
147147
assert mc.keyExists("counterTest123");
148148
log.error("+ counter store test passed");
149149
}

0 commit comments

Comments
 (0)