@Override public Object remove(Object key) { return map.remove(key); }
private void testAllOperations() { ClientCache clientCache = (ClientCache) cache; Region<String, String> region = clientCache.<String, String>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY) .create("internalRegion"); assertFailure(() -> region.create("Object1", "Value1")); assertFailure(() -> region.put("Object1", "Value1")); assertFailure(() -> region.putIfAbsent("Object1", "Value1")); assertFailure(() -> region.get("Object1")); Map<String, String> map = new HashMap<>(); map.put("Object1", "Value1"); assertFailure(() -> region.putAll(map)); List<String> list = new ArrayList<>(); list.add("Object1"); assertFailure(() -> region.getAll(list)); assertFailure(() -> region.removeAll(list)); assertFailure(() -> region.destroy("Object1")); assertFailure(() -> region.remove("Object1")); assertFailure(() -> region.replace("Object1", "oldValue", "newValue")); assertFailure(() -> region.invalidate("Object1")); assertFailure(region::keySetOnServer); assertFailure(() -> region.registerInterest("Object1")); }
private boolean metaRemoveEntry(ByteArrayWrapper key) { return this.redisMetaRegion.remove(key.toString()) != null; }
@Override public boolean remove(Object key, Object value) { try { preOp(); return this.realRegion.remove(key, value); } finally { postOp(); } }
public void unMarkForFederation(ObjectName objName) { synchronized (lock) { if (federatedComponentMap.get(objName) != null) { federatedComponentMap.remove(objName); } if (repo.getLocalMonitoringRegion() != null && repo.getLocalMonitoringRegion().get(objName.toString()) != null) { // To delete an entry from the region repo.getLocalMonitoringRegion().remove(objName.toString()); } } }
@Override public Object remove(Object key) { try { preOp(); return this.realRegion.remove(key); } finally { postOp(); } }
@Override public <K, V> V remove(String regionName, K key) { security.authorize(DATA, WRITE, regionName, key); Region<K, V> region = getRegion(regionName); Object oldValue = region.remove(key); return (V) security.postProcess(regionName, key, oldValue); }
@Override public void run() { getMemcachedRegion(cache).remove(key); expiryFutures.remove(key); if (cache.getLogger().fineEnabled()) { cache.getLogger().fine("expiration removed key:" + key); } } }
@Before public void setUp() throws Exception { regionStub = mock(Region.class); when(regionStub.remove(TEST_KEY)).thenReturn(TEST_VALUE); when(regionStub.containsKey(TEST_KEY)).thenReturn(true); when(regionStub.containsKey(MISSING_KEY)).thenReturn(false); when(cacheStub.getRegion(TEST_REGION)).thenReturn(regionStub); when(cacheStub.getRegion(MISSING_REGION)).thenReturn(null); operationHandler = new RemoveRequestOperationHandler(); }
@Test public void removeIsPostProcessed() { authorize(DATA, WRITE, REGION, "a"); when(region.remove("a")).thenReturn("value"); when(security.postProcess(REGION, "a", "value")).thenReturn("spam"); Object value = authorizingCache.remove(REGION, "a"); verify(region).remove("a"); assertEquals("spam", value); }
@Test public void remove() { authorize(DATA, WRITE, REGION, "a"); authorizingCache.remove(REGION, "a"); verify(region).remove("a"); }
@Override public void executeCommand(Command command, ExecutionHandlerContext context) { List<byte[]> commandElems = command.getProcessedCommand(); if (commandElems.size() < 2) { command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.SPOP)); return; } ByteArrayWrapper key = command.getKey(); @SuppressWarnings("unchecked") Region<ByteArrayWrapper, Boolean> keyRegion = (Region<ByteArrayWrapper, Boolean>) context.getRegionProvider().getRegion(key); if (keyRegion == null || keyRegion.isEmpty()) { command.setResponse(Coder.getNilResponse(context.getByteBufAllocator())); return; } Random rand = new Random(); ByteArrayWrapper[] entries = keyRegion.keySet().toArray(new ByteArrayWrapper[keyRegion.size()]); ByteArrayWrapper pop = entries[rand.nextInt(entries.length)]; keyRegion.remove(pop); if (keyRegion.isEmpty()) { context.getRegionProvider().removeKey(key); } respondBulkStrings(command, context, pop); }
@Test public void processValidKeyRemovesTheEntryAndReturnSuccess() throws Exception { RegionAPI.RemoveRequest removeRequest = generateTestRequest(false, false).getRemoveRequest(); Result result = operationHandler.process(serializationService, removeRequest, TestExecutionContext.getNoAuthCacheExecutionContext(cacheStub)); assertTrue(result instanceof Success); verify(regionStub).remove(TEST_KEY); }
oldVal = keyRegion.remove(new ByteArrayWrapper(commandElems.get(i))); if (oldVal != null) numRemoved++;
Object oldVal = keyRegion.remove(entry); if (oldVal != null) numRemoved++;
byte[] memberArray = commandElems.get(i); ByteArrayWrapper member = new ByteArrayWrapper(memberArray); Object oldVal = keyRegion.remove(member); if (oldVal != null) numDeletedMembers++;
@Override public void executeCommand(Command command, ExecutionHandlerContext context) { List<byte[]> commandElems = command.getProcessedCommand(); if (commandElems.size() < 3) { command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.HDEL)); return; } int numDeleted = 0; ByteArrayWrapper key = command.getKey(); checkDataType(key, RedisDataType.REDIS_HASH, context); Region<ByteArrayWrapper, ByteArrayWrapper> keyRegion = getRegion(context, key); if (keyRegion == null) { command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), numDeleted)); return; } for (int i = START_FIELDS_INDEX; i < commandElems.size(); i++) { ByteArrayWrapper field = new ByteArrayWrapper(commandElems.get(i)); Object oldValue = keyRegion.remove(field); if (oldValue != null) numDeleted++; } if (keyRegion.isEmpty()) { context.getRegionProvider().removeKey(key, RedisDataType.REDIS_HASH); } command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), numDeleted)); }
Object oldVal = keyRegion.remove(removeKey); if (oldVal != null) numRemoved++;
sourceRegion.remove(mem);