Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@navi2589
Last active September 5, 2021 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save navi2589/64cfdd77527d9a3f13519ec125371eb2 to your computer and use it in GitHub Desktop.
Save navi2589/64cfdd77527d9a3f13519ec125371eb2 to your computer and use it in GitHub Desktop.
GetLockOnKey
/*
* Cache the string into Redis with the below set options.
*
* EX seconds -- Set the specified expire time, in seconds.
* NX -- Only set the key if it does not already exist.
*/
public void cacheKeyWithTTL(String key, Long expirySeconds,
boolean isNX, String value, Handler<AsyncResult<String>> handler) {
SetOptions options = new SetOptions();
options.setEX(expirySeconds);
options.setNX(isNX);
redisClient.setWithOptions(key, value, options, handler);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment