瀏覽代碼

add get_withPrefix, for already-prefixed keys

tags/2.0.1
Jonathan Cobb 4 年之前
父節點
當前提交
0bfd8b9c79
共有 1 個檔案被更改,包括 6 行新增1 行删除
  1. +6
    -1
      wizard-server/src/main/java/org/cobbzilla/wizard/cache/redis/RedisService.java

+ 6
- 1
wizard-server/src/main/java/org/cobbzilla/wizard/cache/redis/RedisService.java 查看文件

@@ -114,6 +114,7 @@ public class RedisService {
} }


public String get(String key) { return decrypt(__get(key, 0, MAX_RETRIES)); } public String get(String key) { return decrypt(__get(key, 0, MAX_RETRIES)); }
public String get_withPrefix(String prefixedKey) { return decrypt(__get(prefixedKey, 0, MAX_RETRIES, false)); }


public String get_plaintext(String key) { return __get(key, 0, MAX_RETRIES); } public String get_plaintext(String key) { return __get(key, 0, MAX_RETRIES); }


@@ -316,9 +317,13 @@ public class RedisService {
} }


private String __get(String key, int attempt, int maxRetries) { private String __get(String key, int attempt, int maxRetries) {
return __get(key, attempt, maxRetries, true);
}

private String __get(String key, int attempt, int maxRetries, boolean applyPrefix) {
try { try {
synchronized (redis) { synchronized (redis) {
return getRedis().get(prefix(key));
return getRedis().get(applyPrefix ? prefix(key) : key);
} }
} catch (RuntimeException e) { } catch (RuntimeException e) {
if (attempt > maxRetries) throw e; if (attempt > maxRetries) throw e;


Loading…
取消
儲存