Example usage for org.springframework.cache.support SimpleValueWrapper SimpleValueWrapper

List of usage examples for org.springframework.cache.support SimpleValueWrapper SimpleValueWrapper

Introduction

In this page you can find the example usage for org.springframework.cache.support SimpleValueWrapper SimpleValueWrapper.

Prototype

public SimpleValueWrapper(@Nullable Object value) 

Source Link

Document

Create a new SimpleValueWrapper instance for exposing the given value.

Usage

From source file:com.cetsoft.imcache.spring.ImcacheCacheTest.java

@Test
public void get() {
    cache.put(1, 1);
    assertEquals(new SimpleValueWrapper(1).get(), imcache.get(1).get());
}

From source file:com.googlecode.spring.appengine.cache.memcache.MemcacheCache.java

@Override
public ValueWrapper get(Object key) {
    Object value = memcacheService.get(key);
    return (value != null ? new SimpleValueWrapper(value) : null);
}

From source file:com.cetsoft.imcache.spring.ImcacheCache.java

public ValueWrapper get(Object key) {
    if (key == null) {
        return null;
    }//  ww w .j av  a  2  s.c  om
    final Object value = cache.get(key);
    return value != null ? new SimpleValueWrapper(value) : null;
}

From source file:net.eusashead.spring.gaecache.GaeCacheManagerITCase.java

@Test
public void testCacheManager() throws Exception {
    Cache cache = cacheManager.getCache("default");

    // Check cache is empty
    Assert.assertNotNull(cache);//from  w ww.  jav  a 2 s  . c  o  m
    GaeCacheKey cacheKey = GaeCacheKey.create("key");
    Assert.assertNull(cache.get(cacheKey));

    // Put something in the cache
    cache.put(cacheKey, "foo");
    Assert.assertEquals(new SimpleValueWrapper("foo").get(), cache.get(cacheKey).get());

    // Check consistency
    Assert.assertNotNull(cache.get(cacheKey));
}

From source file:org.hypoport.springGuavaCacheAdapter.SpringGuavaCacheAdapter.java

@Override
public ValueWrapper get(Object key) {
    Optional<Object> value = cache.getIfPresent(key);
    return (value != null ? new SimpleValueWrapper(value.orNull()) : null);
}

From source file:org.vader.common.spring.cache.SerializableCacheProxy.java

@Override
public ValueWrapper get(Object key) {
    final ValueWrapper result = cache.get(key);
    if (result == null) {
        return null;
    }/*from w  ww . j  ava 2 s  .c  o  m*/
    if (result.get() == null) {
        return new SimpleValueWrapper(null);
    }
    try {
        return new SimpleValueWrapper(deserialize((byte[]) result.get()));
    } catch (IOException e) {
        LOG.warn("Unable to deserialize cached value", e);
        return null;
    }
}

From source file:com.zxy.commons.cache.RedisCache.java

@Override
public ValueWrapper get(final Object key) {
    return redisTemplate.execute(new RedisCallback<ValueWrapper>() {
        public ValueWrapper doInRedis(RedisConnection connection) throws DataAccessException {

            byte[] keyb = SerializationUtils.serialize(key);
            byte[] value = connection.get(keyb);
            if (value == null) {
                return null;
            }//  www  .j ava2s . c o  m
            return new SimpleValueWrapper(SerializationUtils.deserialize(value));

        }
    });
}

From source file:com.couchbase.spring.cache.CouchbaseCache.java

/**
 * Get an element from the cache.//  w  ww  .  j a  va 2 s. c  o m
 *
 * @param key the key to lookup against.
 * @return the fetched value from Couchbase.
 */
public final ValueWrapper get(final Object key) {
    String documentId = key.toString();
    Object result = this.client.get(documentId);
    return (result != null ? new SimpleValueWrapper(result) : null);
}

From source file:cz.jirutka.spring.http.client.cache.SynchronizedLruCache.java

protected ValueWrapper createEntry(Object value) {
    return new SimpleValueWrapper(value);
}

From source file:org.springmodules.cache.guava.GuavaCache.java

@Override
public ValueWrapper get(Object key) {
    Object value = this.store.getIfPresent(key);
    return (value != null ? new SimpleValueWrapper(fromStoreValue(value)) : null);
}