@Override public V put(K k, V v) { delegate.putAsync(k,v); return null; }
@Override public void putAll(Map<? extends K, ? extends V> map) { for(Entry<? extends K, ? extends V> entry : map.entrySet()) { delegate.putAsync(entry.getKey(),entry.getValue()); } }
@InvokeOnHeader("PUTASYNC") @InvokeOnHeader(InfinispanConstants.PUT_ASYNC) void onPutAsync(Message message) { final BasicCache<Object, Object> cache = manager.getCache(message, this.cacheName); final Object key = message.getHeader(InfinispanConstants.KEY); final Object value = message.getHeader(InfinispanConstants.VALUE); final CompletableFuture<Object> result; if (hasLifespan(message)) { long lifespan = message.getHeader(InfinispanConstants.LIFESPAN_TIME, long.class); TimeUnit timeUnit = message.getHeader(InfinispanConstants.LIFESPAN_TIME_UNIT, TimeUnit.class); if (hasMaxIdleTime(message)) { long maxIdle = message.getHeader(InfinispanConstants.MAX_IDLE_TIME, long.class); TimeUnit maxIdleTimeUnit = message.getHeader(InfinispanConstants.MAX_IDLE_TIME_UNIT, TimeUnit.class); result = cache.putAsync(key, value, lifespan, timeUnit, maxIdle, maxIdleTimeUnit); } else { result = cache.putAsync(key, value, lifespan, timeUnit); } } else { result = cache.putAsync(key, value); } setResult(message, result); }
/** * @see org.infinispan.commons.api.BasicCache#put(Object, Object, long, TimeUnit) */ public void put(Object key, Object value, long lifespan, TimeUnit unit) { try { if (writeTimeout > 0) this.nativeCache.putAsync(key, value != null ? value : NullValue.NULL, lifespan, unit).get(writeTimeout, TimeUnit.MILLISECONDS); else this.nativeCache.put(key, value != null ? value : NullValue.NULL, lifespan, unit); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new CacheException(e); } catch (ExecutionException | TimeoutException e) { throw new CacheException(e); } }
/** * @see org.springframework.cache.Cache#put(Object, Object) */ @Override public void put(final Object key, final Object value) { try { if (writeTimeout > 0) this.nativeCache.putAsync(key, value != null ? value : NullValue.NULL).get(writeTimeout, TimeUnit.MILLISECONDS); else this.nativeCache.put(key, value != null ? value : NullValue.NULL); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new CacheException(e); } catch (ExecutionException | TimeoutException e) { throw new CacheException(e); } }