@Test public void testAsynchronousAccessFromCache() throws Exception { expect(evCacheImplMock.<String>getAsynchronous("test1")).andReturn(cacheFutureMock); expect(cacheFutureMock.isDone()).andReturn(true); expect(cacheFutureMock.isCancelled()).andReturn(false); expect(cacheFutureMock.get()).andReturn("value1"); replayAll(); EvCacheOptions options = new EvCacheOptions("testApp", "test-cache", true, 100, null, "test{id}"); EvCacheProvider<Object> cacheProvider = new EvCacheProvider<Object>(options); Observable<Object> cacheValue = cacheProvider.get("test1", null); assertEquals("value1", cacheValue.toBlocking().first()); }
@SuppressWarnings("unchecked") @Override public Observable<T> get(final String key, Map<String, Object> requestProperties) { return Observable.create(new OnSubscribe<T>() { @Override public void call(Subscriber<? super T> subscriber) { Future<T> getFuture; try { if (options.getTranscoder() == null) { getFuture = evCache.getAsynchronous(key); } else { getFuture = (Future<T>) evCache.getAsynchronous(key, options.getTranscoder()); } FUTURE_OBSERVER.watchFuture(getFuture, subscriber); } catch (EVCacheException e) { subscriber.onError(new CacheFaultException("EVCache exception when getting value for key " + key, e)); } } }); }
EvCacheProvider implements CacheProvider<T> { @SuppressWarnings("unchecked") @Override public Observable<T> get(final String key, Map<String, Object> requestProperties) { return Observable.create(new OnSubscribe<T>() { @Override public void call(Subscriber<? super T> subscriber) { Future<T> getFuture; try { if (options.getTranscoder() == null) { getFuture = evCache.getAsynchronous(key); } else { getFuture = (Future<T>) evCache.getAsynchronous(key, options.getTranscoder()); } FUTURE_OBSERVER.watchFuture(getFuture, subscriber); } catch (EVCacheException e) { subscriber.onError(new CacheFaultException("EVCache exception when getting value for key " + key, e)); } } }); } }
EvCacheProvider implements CacheProvider<T> { @SuppressWarnings("unchecked") @Override public Observable<T> get(final String key, Map<String, Object> requestProperties) { return Observable.create(new OnSubscribe<T>() { @Override public void call(Subscriber<? super T> subscriber) { Future<T> getFuture; try { if (options.getTranscoder() == null) { getFuture = evCache.getAsynchronous(key); } else { getFuture = (Future<T>) evCache.getAsynchronous(key, options.getTranscoder()); } FUTURE_OBSERVER.watchFuture(getFuture, subscriber); } catch (EVCacheException e) { subscriber.onError(new CacheFaultException("EVCache exception when getting value for key " + key, e)); } } }); } EvCacheProvider(EvCacheOptions options); }
EvCacheProvider implements CacheProvider<T> { @SuppressWarnings("unchecked") @Override public Observable<T> get(final String key, Map<String, Object> requestProperties) { return Observable.create(new OnSubscribe<T>() { @Override public void call(Subscriber<? super T> subscriber) { Future<T> getFuture; try { if (options.getTranscoder() == null) { getFuture = evCache.getAsynchronous(key); } else { getFuture = (Future<T>) evCache.getAsynchronous(key, options.getTranscoder()); } FUTURE_OBSERVER.watchFuture(getFuture, subscriber); } catch (EVCacheException e) { subscriber.onError(new CacheFaultException("EVCache exception when getting value for key " + key, e)); } } }); } EvCacheProvider(EvCacheOptions options); @SuppressWarnings("unchecked") @Override Observable<T> get(final String key, Map<String, Object> requestProperties); }
EvCacheProvider implements CacheProvider<T> { @SuppressWarnings("unchecked") @Override public Observable<T> get(final String key, Map<String, Object> requestProperties) { return Observable.create(new OnSubscribe<T>() { @Override public void call(Subscriber<? super T> subscriber) { Future<T> getFuture; try { if (options.getTranscoder() == null) { getFuture = evCache.getAsynchronous(key); } else { getFuture = (Future<T>) evCache.getAsynchronous(key, options.getTranscoder()); } FUTURE_OBSERVER.watchFuture(getFuture, subscriber); } catch (EVCacheException e) { subscriber.onError(new CacheFaultException("EVCache exception when getting value for key " + key, e)); } } }); } EvCacheProvider(EvCacheOptions options); @SuppressWarnings("unchecked") @Override Observable<T> get(final String key, Map<String, Object> requestProperties);  }