public <T> T get(Object key, Class<T> type) { Object value = map.get(key); if (value == null) { addCacheMiss(); }else{ addCacheHit(); if (value.getClass().getName().equals(NullValue.class.getName())) { return null; } if (type != null && !type.isInstance(value)) { throw new IllegalStateException("Cached value is not of required type [" + type.getName() + "]: " + value); } } return (T) fromStoreValue(value); }
@Override public void run() { try { this.codec = (Codec) codecClass.getConstructor().newInstance(); } catch (Exception e) { throw new IllegalArgumentException(e); } Injector.inject(reducer, redisson); RMap<KOut, VOut> map = redisson.getMap(resultMapName); RListMultimap<KOut, VOut> multimap = redisson.getListMultimap(name, codec); for (KOut key : multimap.keySet()) { if (Thread.currentThread().isInterrupted()) { break; } List<VOut> values = multimap.get(key); VOut out = reducer.reduce(key, values.iterator()); map.put(key, out); } if (timeout > 0) { map.expire(timeout, TimeUnit.MILLISECONDS); } multimap.delete(); }
@Override public void put(Object key, Object value) { if (!allowNullValues && value == null) { map.remove(key); return; } value = toStoreValue(value); if (mapCache != null) { mapCache.fastPut(key, value, config.getTTL(), TimeUnit.MILLISECONDS, config.getMaxIdleTime(), TimeUnit.MILLISECONDS); } else { map.fastPut(key, value); } }
public ValueWrapper putIfAbsent(Object key, Object value) { Object prevValue; if (!allowNullValues && value == null) { prevValue = map.get(key); } else { value = toStoreValue(value); if (mapCache != null) { prevValue = mapCache.putIfAbsent(key, value, config.getTTL(), TimeUnit.MILLISECONDS, config.getMaxIdleTime(), TimeUnit.MILLISECONDS); } else { prevValue = map.putIfAbsent(key, value); } } return toValueWrapper(prevValue); }
map.put("a", 1); map.put("b", 2); map.put("c", 3); boolean contains = map.containsKey("a"); Integer value = map.get("c"); Integer updatedValue = map.addAndGet("a", 32); Integer valueSize = map.valueSize("c"); keys.add("b"); keys.add("c"); Map<String, Integer> mapSlice = map.getAll(keys); Set<String> allKeys = map.readAllKeySet(); Collection<Integer> allValues = map.readAllValues(); Set<Entry<String, Integer>> allEntries = map.readAllEntrySet(); boolean isNewKey = map.fastPut("a", 100); boolean isNewKeyPut = map.fastPutIfAbsent("d", 33); long removedAmount = map.fastRemove("b");
Object result = liveMap.get(fieldName); if (result == null) { RObject ar = objectBuilder.createObject(((RLiveObject) me).getLiveObjectId(), me.getClass().getSuperclass(), fieldType, fieldName, redisson); liveMap.fastPut(fieldName, new RedissonReference(rEntity, ns.getName(rEntity, fieldType, getREntityIdFieldName(liveObject), liveObject.getLiveObjectId()))); Object oldArg = liveMap.remove(fieldName); if (field.getAnnotation(RIndex.class) != null) { NamingScheme namingScheme = objectBuilder.getNamingScheme(me.getClass().getSuperclass()); storeIndex(field, me, arg); liveMap.fastPut(fieldName, arg);
if (map.getName().equals(idKey)) { return null; map.rename(getMapKey(args[0])); } catch (RedisException e) { if (e.getMessage() == null || !e.getMessage().startsWith("ERR no such key")) { return null; return namingScheme.resolveId(map.getName()); return map.isExists(); for (InDefinedShape field : fields) { String fieldName = field.getName(); Object value = map.get(fieldName); NamingScheme namingScheme = objectBuilder.getNamingScheme(me.getClass().getSuperclass()); String indexName = namingScheme.getIndexName(me.getClass().getSuperclass(), fieldName); idsMultimap.removeAsync(value, ((RLiveObject) me).getLiveObjectId()); RFuture<Long> deleteFuture = batch.getKeys().deleteAsync(map.getName()); batch.execute();
@Override public String changeSessionId() { String id = delegate.changeSessionId(); if (redisson.getConfig().isClusterConfig()) { Map<String, Object> oldState = map.readAllMap(); map.delete(); map = redisson.getMap(keyPrefix + id, map.getCodec()); map.putAll(oldState); } else { map.rename(keyPrefix + id); } return id; }
@Override public void delete(String path) { if (map != null) { map.remove(path); } }
@Override public void run() { RMap<String, String> map = redisson.getMap("myMap"); map.put("5", "11"); }
try { if (readMode == ReadMode.MEMORY) { attrs = getMap(id).readAllMap(); } else { attrs = getMap(id).getAll(RedissonSession.ATTRS);
@Override public void evict(Object key) { map.fastRemove(key); }
@Override public void setLastAccessedTime(long lastAccessedTime) { delegate.setLastAccessedTime(lastAccessedTime); if (map != null) { map.fastPut("session:lastAccessedTime", lastAccessedTime); updateExpiration(); } }
@Override public void setCreationTime(long time) { super.setCreationTime(time); if (map != null) { Map<String, Object> newMap = new HashMap<String, Object>(3); newMap.put(CREATION_TIME_ATTR, creationTime); newMap.put(LAST_ACCESSED_TIME_ATTR, lastAccessedTime); newMap.put(THIS_ACCESSED_TIME_ATTR, thisAccessedTime); map.putAll(newMap); if (readMode == ReadMode.MEMORY) { topic.publish(createPutAllMessage(newMap)); } } }
public void delete() { map.delete(); }
protected void expireSession() { if (maxInactiveInterval >= 0) { map.expire(maxInactiveInterval + 60, TimeUnit.SECONDS); } }
@Override public void setValid(boolean isValid) { super.setValid(isValid); if (map != null) { if (!isValid && !map.isExists()) { return; } fastPut(IS_VALID_ATTR, isValid); } }
public Iterator<GeoWaveRow> getRows(final byte[][] dataIds, final short adapterId) { final Map<byte[], byte[]> results = getCurrentSyncCollection().getAll(new HashSet<>(Arrays.asList(dataIds))); return Arrays.stream(dataIds).map( dataId -> DataIndexUtils.deserializeDataIndexRow( dataId, adapterId, results.get(dataId), visibilityEnabled)).iterator(); }