Java Code Examples for org.redisson.api.RLocalCachedMap#readAllValues()
The following examples show how to use
org.redisson.api.RLocalCachedMap#readAllValues() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedissonLocalCachedMapTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testReadValuesAndEntries() { RLocalCachedMap<Object, Object> m = redisson.getLocalCachedMap("testValuesWithNearCache2", LocalCachedMapOptions.defaults()); m.clear(); m.put("a", 1); m.put("b", 2); m.put("c", 3); Set<Integer> expectedValuesSet = new HashSet<>(); expectedValuesSet.add(1); expectedValuesSet.add(2); expectedValuesSet.add(3); Set<Object> actualValuesSet = new HashSet<>(m.readAllValues()); Assert.assertEquals(expectedValuesSet, actualValuesSet); Map<String, Integer> expectedMap = new HashMap<>(); expectedMap.put("a", 1); expectedMap.put("b", 2); expectedMap.put("c", 3); Assert.assertEquals(expectedMap.entrySet(), m.readAllEntrySet()); }
Example 2
Source File: LocalCachedMapExamples.java From redisson-examples with Apache License 2.0 | 5 votes |
public static void main(String[] args) { // connects to 127.0.0.1:6379 by default RedissonClient redisson = Redisson.create(); LocalCachedMapOptions options = LocalCachedMapOptions.defaults() .cacheSize(10000) .evictionPolicy(EvictionPolicy.LRU) .maxIdle(10, TimeUnit.SECONDS) .timeToLive(60, TimeUnit.SECONDS); RLocalCachedMap<String, Integer> cachedMap = redisson.getLocalCachedMap("myMap", options); cachedMap.put("a", 1); cachedMap.put("b", 2); cachedMap.put("c", 3); boolean contains = cachedMap.containsKey("a"); Integer value = cachedMap.get("c"); Integer updatedValue = cachedMap.addAndGet("a", 32); Integer valueSize = cachedMap.valueSize("c"); Set<String> keys = new HashSet<String>(); keys.add("a"); keys.add("b"); keys.add("c"); Map<String, Integer> mapSlice = cachedMap.getAll(keys); // use read* methods to fetch all objects Set<String> allKeys = cachedMap.readAllKeySet(); Collection<Integer> allValues = cachedMap.readAllValues(); Set<Entry<String, Integer>> allEntries = cachedMap.readAllEntrySet(); // use fast* methods when previous value is not required boolean isNewKey = cachedMap.fastPut("a", 100); boolean isNewKeyPut = cachedMap.fastPutIfAbsent("d", 33); long removedAmount = cachedMap.fastRemove("b"); redisson.shutdown(); }