2222 * Built ontop of the StructCache_KeyValueMap implementation.
2323 **/
2424public class StructCache_KeyValueMap extends Core_KeyValueMap {
25-
25+
2626 //--------------------------------------------------------------------------
2727 //
2828 // Constructor
@@ -59,14 +59,14 @@ static public class CacheValue implements Serializable {
5959 public String value ;
6060 public long expire ;
6161 }
62-
62+
6363 static CacheValue cacheValueBuilder (String val , long exp ) {
6464 CacheValue ret = new CacheValue ();
6565 ret .value = val ;
6666 ret .expire = exp ;
6767 return ret ;
6868 }
69-
69+
7070 /**
7171 * Global static cache map,
7272 * Used to persist all the various cache maps used.
@@ -158,32 +158,33 @@ public void systemSetup() {
158158 }
159159
160160 // Build the cache
161- Cache2kBuilder <String , CacheValue > builder = new Cache2kBuilder <String , CacheValue >(){};
161+ Cache2kBuilder <String , CacheValue > builder = new Cache2kBuilder <String , CacheValue >() {
162+ };
162163 builder .storeByReference (true );
163164 _valueMap = StructCacheUtil .setupCache2kMap (builder , cacheName (), configMap ());
164165
165166 // Add it back to the global cache
166167 globalCacheMap .put (cacheName (), _valueMap );
167168 }
168-
169+
169170 }
170-
171+
171172 @ Override
172173 public void systemDestroy () {
173174 synchronized (StructCache_KeyValueMap .class ) {
174175 _valueMap .clear ();
175176 globalCacheMap .remove (cacheName ());
176177 _valueMap = null ;
177178 }
178-
179+
179180 }
180-
181+
181182 @ Override
182183 public void maintenance () {
183184 // Does nothing
184-
185+
185186 }
186-
187+
187188 //--------------------------------------------------------------------------
188189 //
189190 // Set and get values
@@ -203,21 +204,21 @@ public void maintenance() {
203204 @ Override
204205 public String setValueRaw (String key , String value , long expire ) {
205206 // Handles null removal
206- if ( value == null ) {
207+ if ( value == null ) {
207208 valueMap ().remove (key );
208209 return null ;
209210 }
210-
211+
211212 // Store and configure expiry
212213 valueMap ().put (key , cacheValueBuilder (value , expire ));
213- if ( expire > 0 ) {
214+ if ( expire > 0 ) {
214215 // Note that cache expiry config, may take priority
215216 // so this should not be relied on in itself
216217 valueMap ().expireAt (key , expire );
217218 }
218219 return null ;
219220 }
220-
221+
221222 /**
222223 * [Internal use, to be extended in future implementation]
223224 * Sets the expire time stamp value, raw without validation
@@ -230,22 +231,22 @@ public String setValueRaw(String key, String value, long expire) {
230231 @ Override
231232 public void setExpiryRaw (String key , long time ) {
232233 CacheValue cv = valueMap ().get (key );
233- if ( cv == null ) {
234+ if ( cv == null ) {
234235 // Does nothing if cv == null
235236 return ;
236237 }
237-
238+
238239 // Set the actual expire value
239240 cv .expire = time ;
240-
241+
241242 // Configure cache2k expire values
242- if ( time > 0 ) {
243+ if ( time > 0 ) {
243244 // Note that cache expiry config, may take priority
244245 // so this should not be relied on in itself
245246 valueMap ().expireAt (key , time );
246247 }
247248 }
248-
249+
249250 /**
250251 * [Internal use, to be extended in future implementation]
251252 *
@@ -259,15 +260,15 @@ public void setExpiryRaw(String key, long time) {
259260 @ Override
260261 public MutablePair <String , Long > getValueExpiryRaw (String key , long now ) {
261262 CacheValue cv = valueMap ().get (key );
262- if ( cv == null ) {
263+ if ( cv == null ) {
263264 // Does nothing if cv == null
264265 return null ;
265266 }
266- if ( cv .expire > 0 && cv .expire <= System .currentTimeMillis () ) {
267+ if ( cv .expire > 0 && cv .expire <= System .currentTimeMillis ()) {
267268 // Value should be expired, does nothing
268269 return null ;
269270 }
270- return new MutablePair <String ,Long >(cv .value , cv .expire );
271+ return new MutablePair <String , Long >(cv .value , cv .expire );
271272 }
272273
273274 //--------------------------------------------------------------------------
@@ -279,33 +280,33 @@ public MutablePair<String, Long> getValueExpiryRaw(String key, long now) {
279280 @ Override
280281 public Set <String > keySet (String value ) {
281282 // Optimized for all
282- if ( value == null ) {
283+ if ( value == null ) {
283284 return valueMap ().asMap ().keySet ();
284285 }
285-
286+
286287 // We have to do a search
287288 Set <String > full = valueMap ().asMap ().keySet ();
288289 Set <String > ret = new HashSet <>();
289290 long now = System .currentTimeMillis ();
290-
291+
291292 // Lets iterate each key
292- for (String key : full ) {
293+ for (String key : full ) {
293294 CacheValue cv = valueMap ().get (key );
294- if ( cv == null ) {
295+ if ( cv == null ) {
295296 // Does nothing if cv == null
296297 continue ;
297298 }
298- if ( cv .expire > 0 && cv .expire <= now ) {
299+ if ( cv .expire > 0 && cv .expire <= now ) {
299300 // Value should be expired, does nothing
300301 continue ;
301302 }
302- if ( cv .value == value ) {
303+ if ( cv .value == value ) {
303304 ret .add (key );
304305 }
305306 }
306-
307+
307308 // Return the filtered set
308309 return ret ;
309310 }
310-
311+
311312}
0 commit comments