@Override public <T> T get(Object key, Class<T> type) { try { Object value; if (readTimeout > 0) value = nativeCache.getAsync(key).get(readTimeout, TimeUnit.MILLISECONDS); else value = nativeCache.get(key); value = unwrapNull(value); if (value != null && type != null && !type.isInstance(value)) { throw new IllegalStateException("Cached value is not of required type [" + type.getName() + "]: " + value); } return (T) value; } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new CacheException(e); } catch (ExecutionException | TimeoutException e) { throw new CacheException(e); } }
/** * @see org.springframework.cache.Cache#get(Object) */ @Override public ValueWrapper get(final Object key) { try { if (readTimeout > 0) return wrap(nativeCache.getAsync(key).get(readTimeout, TimeUnit.MILLISECONDS)); else return wrap(nativeCache.get(key)); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new CacheException(e); } catch (ExecutionException | TimeoutException e) { throw new CacheException(e); } }