-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add methods to list the keys #28
Conversation
… and startwith-ifalive
This solves malformed code and it runs! |
1 similar comment
@@ -80,6 +83,33 @@ public void set(String key, T value, long keepAliveInMillis) { | |||
} | |||
} | |||
|
|||
public List<String> listCachedKeysStartingWith(String keyStartingWith) { | |||
List<String> keys = new ArrayList<String>(); | |||
keyStartingWith = getEffectiveKey(keyStartingWith); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not calling it "key" or "effectiveKey" ? Reusing an input parameter is not an issue in this case, but if we call it "effectiveKey" we will be sure that the key has been translated when using it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double morality Mr. Roc?
public void set(String key, T value, long keepAliveInMillis) {
key = getEffectiveKey(key);
from QNCache.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hahahaha nope! Evolution! Btw, thanks for spotting it! :-)
|
||
for (String key : Collections.list(cache.keys())) { | ||
if (key.startsWith(keyStartingWith)) { | ||
keys.add(key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wep, autoformat the code, please :·D
|
||
public List<String> listCachedKeysStartingWithIfAlive(String keyStartingWith) { | ||
List<String> keys = new ArrayList<String>(); | ||
final long now = now(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why final? We could avoid this as it doesn't add any value... just code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old java 8 code needs it and I forgot to change.
return keys; | ||
} | ||
|
||
public List<String> listCachedKeysStartingWithIfAlive(String keyStartingWith) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about listAliveCachedKeysStartingWith
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waw!
It will clarify its behavior. ListCachedKeys and ListCachedKeysStartingWith?
Roc from past says!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hihi and now, looking at the implementation of Java's Map, I see that Java call this method keySet()
. What do you think about calling it keySetStartingWith
? Some thoughts there...
@juanet3 thanks for the code! BTW, what do you think about removing the "cached" word of the methods? When the people uses this librarby, it would write something like BTW, could you add a simpler method |
@juanet3 as your PR gives a lot of value to the project, do you want me to implement my own suggetions? It would be great to launch a release with your additions :·) |
Going to merge these changes and apply my suggestions to master :·) |
Solving some midnight bugs