Browse Source

getCounter 挪至 incr 下方

James 5 years ago
parent
commit
a09182b006
1 changed files with 12 additions and 12 deletions
  1. 12 12
      src/main/java/com/jfinal/plugin/redis/Cache.java

+ 12 - 12
src/main/java/com/jfinal/plugin/redis/Cache.java

@@ -223,6 +223,18 @@ public class Cache {
 	}
 	
 	/**
+	 * 获取记数器的值
+	 */
+	public Long getCounter(Object key) {
+		Jedis jedis = getJedis();
+		try {
+			String ret = (String)jedis.get(keyNamingPolicy.getKeyName(key));
+			return ret != null ? Long.parseLong(ret) : null;
+		}
+		finally {close(jedis);}
+	}
+	
+	/**
 	 * 将 key 所储存的值加上增量 increment 。
 	 * 如果 key 不存在,那么 key 的值会先被初始化为 0 ,然后再执行 INCRBY 命令。
 	 * 如果值包含错误的类型,或字符串类型的值不能表示为数字,那么返回一个错误。
@@ -654,18 +666,6 @@ public class Cache {
 	}
 	
 	/**
-	 * 获取记数器的值
-	 */
-	public Long getCounter(Object key) {
-		Jedis jedis = getJedis();
-		try {
-			String ret = (String)jedis.get(keyNamingPolicy.getKeyName(key));
-			return ret != null ? Long.parseLong(ret) : null;
-		}
-		finally {close(jedis);}
-	}
-	
-	/**
 	 * 返回列表 key 的长度。
 	 * 如果 key 不存在,则 key 被解释为一个空列表,返回 0 .
 	 * 如果 key 不是列表类型,返回一个错误。