@Override ICompletableFuture storeAsync(K key, V value) { return (ICompletableFuture) cache.putAsync(key, value); } }
@Override public ICompletableFuture<Void> putAsync(K key, V value) { return cache.putAsync(key, value); }
@Override public ICompletableFuture<Void> setAsync(K key, V value) { return cache.putAsync(key, value); }
@Override ICompletableFuture storeAsync(K key, V value) { return (ICompletableFuture) cache.putAsync(key, value); } }
@Override ICompletableFuture storeAsync(K key, V value) { return (ICompletableFuture) cache.putAsync(key, value); } }
@Override public ICompletableFuture<Void> setAsync(K key, V value) { return cache.putAsync(key, value); }
@Override public ICompletableFuture<Void> setAsync(K key, V value, ExpiryPolicy expiryPolicy) { return cache.putAsync(key, value, expiryPolicy); }
@Override public ICompletableFuture<Void> putAsync(K key, V value, ExpiryPolicy expiryPolicy) { return cache.putAsync(key, value, expiryPolicy); }
@Override public ICompletableFuture<Void> setAsync(K key, V value, ExpiryPolicy expiryPolicy) { return cache.putAsync(key, value, expiryPolicy); }
@TimeStep(prob = 0.1) public void write(ThreadState state) throws Exception { Integer key = state.randomInt(keyCount); Integer value = state.randomInt(); ICompletableFuture<?> future = cache.putAsync(key, value); state.futureList.add(future); state.syncIfNecessary(state.iteration++); }
@TimeStep(prob = 0.1) public void putAsync(ThreadState state) { int key = state.randomInt(); cache.putAsync(key, value); state.counter.putAsync++; state.assertSize(); }
@TimeStep(prob = 0.3) public void putAsync(ThreadState state) { int key = state.randomInt(keyCount); cache.putAsync(key, state.randomLong(), expiryPolicy); state.counter.putAsyncExpiry++; }
System.out.println("Get value as async with key \"key1\": " + future.get()); cache.putAsync("key1", "value2"); System.out.println("Put value \"value2\" as async with key \"key1\"");
cache.putAsync(key, getRandom().nextLong(), expiryPolicy); counter.putAsyncExpiry++; break;
public static void main(String[] args) { // Run as a Hazelcast Client System.setProperty("hazelcast.jcache.provider.type", "client"); // Create the JCache CacheManager CacheManager manager = Caching.getCachingProvider().getCacheManager(); MutableConfiguration<String, String> configuration = new MutableConfiguration<String, String>(); // Expire entries after 1 minute configuration.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.ONE_MINUTE)); // Get a Cache called "myCache" and configure with 1 minute expiry Cache<String, String> myCache = manager.createCache("myCache", configuration); // Put and Get a value from "myCache" myCache.put("key", "value"); String value = myCache.get("key"); System.out.println(value); //ICache is a Hazelcast interface that extends JCache, provides more functionality ICache<String, String> icache = myCache.unwrap(ICache.class); //Async Get and Put using ICache interface icache.getAsync("key"); icache.putAsync("key", "value"); //ICache allows custom expiry per cache entry final ExpiryPolicy customExpiryPolicy = AccessedExpiryPolicy.factoryOf(Duration.TEN_MINUTES).create(); icache.put("key", "newValue", customExpiryPolicy); //Size of the Cache should reflect the ICache and JCache operations icache.size(); //Shutdown this Hazelcast Client manager.getCachingProvider().close(); } }
public static void main(String[] args) { // Run as a Hazelcast Member System.setProperty("hazelcast.jcache.provider.type", "server"); // Create the JCache CacheManager CacheManager manager = Caching.getCachingProvider().getCacheManager(); MutableConfiguration<String, String> configuration = new MutableConfiguration<String, String>(); // Expire entries after 1 minute configuration.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.ONE_MINUTE)); // Get a Cache called "myCache" and configure with 1 minute expiry Cache<String, String> myCache = manager.createCache("myCache", configuration); // Put and Get a value from "myCache" myCache.put("key", "value"); String value = myCache.get("key"); System.out.println(value); //ICache is a Hazelcast interface that extends JCache, provides more functionality ICache<String, String> icache = myCache.unwrap(ICache.class); //Async Get and Put using ICache interface icache.getAsync("key"); icache.putAsync("key", "value"); //ICache allows custom expiry per cache entry final ExpiryPolicy customExpiryPolicy = AccessedExpiryPolicy.factoryOf(Duration.TEN_MINUTES).create(); icache.put("key", "newValue", customExpiryPolicy); //Size of the Cache should reflect the ICache and JCache operations icache.size(); //Shutdown the underlying Hazelcast Cluster Member manager.getCachingProvider().close(); } }