Write single key=value to redis with lookup_set_value

This commit is contained in:
yo000 2024-02-03 17:00:04 +01:00
parent d0c4938e38
commit 69cddd64f7

View File

@ -147,8 +147,6 @@ public class RedisLookupDataAdapter extends LookupDataAdapter {
return LookupResult.empty(); return LookupResult.empty();
} }
return LookupResult.single(value); return LookupResult.single(value);
//return LookupResult.single("coincoin");
} catch (Exception e) { } catch (Exception e) {
LOG.error("Redis GET request error for key <{}>", trimmedKey, e); LOG.error("Redis GET request error for key <{}>", trimmedKey, e);
redisGetRequestErrors.mark(); redisGetRequestErrors.mark();
@ -158,23 +156,27 @@ public class RedisLookupDataAdapter extends LookupDataAdapter {
} }
} }
// This is deprecated, see setValue
@Override @Override
public void set(Object key, Object value) { public void set(Object key, Object value) {
//throw new UnsupportedOperationException(); return;
LOG.warn("Entering Redis set function with {}={}", key.toString(), value.toString()); }
@Override
public LookupResult setValue(Object key, Object value) {
final Timer.Context time = redisSetRequestTimer.time(); final Timer.Context time = redisSetRequestTimer.time();
try { try {
final String result = this.commands.set(key.toString(), value.toString()); final String result = this.commands.set(key.toString(), value.toString());
if (!result.equals("OK")) { if (!result.equals("OK")) {
LOG.warn("Redis SET key <{}> to value <{}> returned {}", key, value, result); LOG.warn("Redis SET key <{}> to value <{}> returned {}", key, value, result);
redisSetRequestErrors.mark(); redisSetRequestErrors.mark();
return; return LookupResult.empty();
} }
return; return LookupResult.single(value.toString());
} catch (Exception e) { } catch (Exception e) {
LOG.error("Redis SET key <{}> to value <{}> returned an exception: {}", key, value, e); LOG.error("Redis SET key <{}> to value <{}> returned an exception: {}", key, value, e);
redisSetRequestErrors.mark(); redisSetRequestErrors.mark();
return; return LookupResult.empty();
} finally { } finally {
time.stop(); time.stop();
} }