@@ -43,8 +43,6 @@ public class Redis_KeyValueMap extends Core_KeyValueMap {
4343 /** Redis instance representing the backend connection */
4444 RedisStack redisStack = null ;
4545 RedissonClient redisson = null ;
46- // RMap<String, Object> redisMap = null;
47- RMap <String , String > redisMap = null ;
4846
4947 /**
5048 * Constructor, with name constructor
@@ -56,7 +54,6 @@ public Redis_KeyValueMap(RedisStack inStack, String name) {
5654 super ();
5755 redisStack = inStack ;
5856 redisson = inStack .getConnection ();
59- redisMap = redisson .getMap (name , JsonJacksonCodec .INSTANCE );
6057 }
6158
6259 //--------------------------------------------------------------------------
@@ -164,21 +161,25 @@ public void maintenance() {
164161 * @return array of keys
165162 **/
166163 @ Override
167- public Set <String > keySet (String value ) { //TODO
164+ public Set <String > keySet (String value ) {
168165 // The return hashset
169166 HashSet <String > ret = new HashSet <String >();
170- //Fetch everything in current db
171167 List <String > retList = null ;
172- if (value != null ) {
173- //backendMap().get(value);
174- //retList = new ArrayList<String>(backendMap().readAllKeySet());
168+ if (value == null ) {
169+ // Lets fetch everything
175170 retList = new ArrayList <String >(backendMap ().readAllKeySet ());
176171 // Return the full keyset
177172 retList .forEach (k -> ret .add (k ));
173+ } else {
174+ //TODO: not sure abt keyset() vs readAllKeySet()
175+ retList = new ArrayList <String >(backendMap ().keySet ());
176+ for (String key : retList ) {
177+ String val = backendMap ().get (key );
178+ if (value .equals (val )) {
179+ ret .add (key );
180+ }
181+ }
178182 }
179- retList = new ArrayList <String >(backendMap ().readAllKeySet ());
180- // Return the full keyset
181- retList .forEach (k -> ret .add (k ));
182183 return ret ;
183184 }
184185
@@ -235,7 +236,7 @@ public String setValueRaw(String key, String value, long expire) {
235236 backendMap ().fastPut (key , value , Math .max (expire - System .currentTimeMillis (), 1 ),
236237 TimeUnit .MILLISECONDS );
237238 } else {
238- backendMap ().put (key , value );
239+ backendMap ().fastPut (key , value );
239240 }
240241 return null ;
241242 }
@@ -257,7 +258,6 @@ public MutablePair<String, Long> getValueExpiryRaw(String key, long now) {
257258 Set <String > keys = new HashSet <String >();
258259 Map <String , String > mapSlice = new HashMap <String , String >();
259260 Map .Entry <String ,String > entry = null ;
260- String value = null ;
261261
262262 keys .add (key );
263263 mapSlice = backendMap ().getAll (keys );
@@ -268,17 +268,13 @@ public MutablePair<String, Long> getValueExpiryRaw(String key, long now) {
268268 if (entry == null ) {
269269 return null ;
270270 }
271- value = entry .getValue ();
271+ String value = entry .getValue ();
272272
273- //Cheating there because I don't think redisson has Map Entry Eviction according to this:
274- //https://www.javadoc.io/doc/org.redisson/redisson/3.2.0/org/redisson/api/RMapCache.html
275- Long expireObj = 0L ;
276-
273+ Long expireObj = backendMap ().remainTimeToLive (key ) + System .currentTimeMillis ();
277274 // Note: 0 = no timestamp, hence valid value
278275 long expiry = expireObj .longValue ();
279276 return new MutablePair <String , Long >(value , expiry );
280277 }
281278 return null ;
282279 }
283-
284280}
0 commit comments