当前位置: 首页>>代码示例>>Java>>正文


Java SimpleValueWrapper类代码示例

本文整理汇总了Java中org.springframework.cache.support.SimpleValueWrapper的典型用法代码示例。如果您正苦于以下问题:Java SimpleValueWrapper类的具体用法?Java SimpleValueWrapper怎么用?Java SimpleValueWrapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SimpleValueWrapper类属于org.springframework.cache.support包,在下文中一共展示了SimpleValueWrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: get

import org.springframework.cache.support.SimpleValueWrapper; //导入依赖的package包/类
@Override
public ValueWrapper get(Object key) {
    checkNotNull(key, "null key is not allowed");
    checkArgument(key instanceof Serializable, "key must implements Serializable");
    Serializable sValue = codisTemplate.opsForValue().get(key);
    if (Objects.nonNull(sValue)) {
        if (log.isDebugEnabled()) {
            log.debug("get object [{}] from cache by key [{}]", sValue, key);
        }
        return new SimpleValueWrapper(sValue);
    } else {
        if (log.isDebugEnabled()) {
            log.debug("get object [{}] from cache by key [{}]", null, key);
        }
        return null;
    }
}
 
开发者ID:srarcbrsent,项目名称:tc,代码行数:18,代码来源:TcCodisCache.java

示例2: getAndPutFail

import org.springframework.cache.support.SimpleValueWrapper; //导入依赖的package包/类
@Test
public void getAndPutFail() {
    final UnsupportedOperationException exception = new UnsupportedOperationException(
            "Test exception on get");
    willThrow(exception).given(this.cache).get(0L);
    willThrow(exception).given(this.cache).put(0L, 0L); // Update of the cache will
                                                        // fail as well

    final Object counter = this.simpleService.get(0L);

    willReturn(new SimpleValueWrapper(2L)).given(this.cache).get(0L);
    final Object counter2 = this.simpleService.get(0L);
    final Object counter3 = this.simpleService.get(0L);
    assertThat(counter2).isEqualTo(counter3);
    assertThat(counter).isNotEqualTo(counter2);
}
 
开发者ID:rajadilipkolli,项目名称:POC,代码行数:17,代码来源:CustomCacheErrorHandlerTest.java

示例3: get

import org.springframework.cache.support.SimpleValueWrapper; //导入依赖的package包/类
@Override
public ValueWrapper get(final Object key) {
    if (!cache.isEnabled()) {
        LOGGER.warn("Cache {} is disabled. Cannot get {} from cache", cache.getName(), key);
        return null;
    }

    Object value = getValue(key);
    if (value == null) {
        LOGGER.info("Cache miss. Get by key {} from cache {}", key, cache.getName());
        return null;
    }

    LOGGER.info("Cache hit. Get by key {} from cache {} value '{}'", new Object[] { key, cache.getName(), value });
    return value instanceof PertinentNegativeNull ? new SimpleValueWrapper(null) : new SimpleValueWrapper(value);
}
 
开发者ID:ragnor,项目名称:simple-spring-memcached,代码行数:17,代码来源:SSMCache.java

示例4: get

import org.springframework.cache.support.SimpleValueWrapper; //导入依赖的package包/类
@Override
public ValueWrapper get(Object key) {
  Object value = null;
  String cacheKey = null;
  try {
    cacheKey = createArcusKey(key);
    logger.debug("getting value by key: {}", cacheKey);

    Future<Object> future;

    // operation transcoder can't be null.
    if (operationTranscoder != null) {
      future = arcusClient.asyncGet(cacheKey, operationTranscoder);
    } else {
      future = arcusClient.asyncGet(cacheKey);
    }

    value = future.get(timeoutMilliSeconds, TimeUnit.MILLISECONDS);
  } catch (Exception e) {
    logger.debug(e.getMessage());
    if (wantToGetException) {
      throw new RuntimeException(e);
    }
  }
  return (value != null ? new SimpleValueWrapper(value) : null);
}
 
开发者ID:naver,项目名称:arcus-spring,代码行数:27,代码来源:ArcusCache.java

示例5: get

import org.springframework.cache.support.SimpleValueWrapper; //导入依赖的package包/类
@Override
public Object get(Object key) throws CacheException {
	Object value = springCache.get(key);
	if (value instanceof SimpleValueWrapper) {
		return ((SimpleValueWrapper) value).get();
	}
	return value;
}
 
开发者ID:jiangzongyao,项目名称:kettle_support_kettle8.0,代码行数:9,代码来源:SpringCacheManager.java

示例6: get

import org.springframework.cache.support.SimpleValueWrapper; //导入依赖的package包/类
@Override
public ValueWrapper get(Object key) {
    Assert.notNull(key);
    Object val = memcacheService.get(key);
    if (val == null) {
        return null;
    }
    if (val == NullValue.INSTANCE) {
        val = null;
    }
    return new SimpleValueWrapper(val);
}
 
开发者ID:bartprokop,项目名称:nice-api,代码行数:13,代码来源:MemCache.java

示例7: toValueWrapper

import org.springframework.cache.support.SimpleValueWrapper; //导入依赖的package包/类
private ValueWrapper toValueWrapper(Object value) {
    if (value == null) {
        return null;
    }
    if (value.getClass().getName().equals(NullValue.class.getName())) {
        return NullValue.INSTANCE;
    }
    return new SimpleValueWrapper(value);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:10,代码来源:RedissonCache.java

示例8: get

import org.springframework.cache.support.SimpleValueWrapper; //导入依赖的package包/类
@Override
public Object get(Object key) throws CacheException {
    Object value = springCache.get(key);
    if (value instanceof SimpleValueWrapper) {
        return ((SimpleValueWrapper) value).get();
    }
    return value;
}
 
开发者ID:liaojiacan,项目名称:zkAdmin,代码行数:9,代码来源:SpringCacheManagerWrapper.java

示例9: get

import org.springframework.cache.support.SimpleValueWrapper; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public V get(K key) throws CacheException {
   	ValueWrapper value = cache.get(key);
       if (value instanceof SimpleValueWrapper) {
           return (V)((SimpleValueWrapper) value).get();
       }
       return (V)value;
   }
 
开发者ID:wjggwm,项目名称:webside,代码行数:9,代码来源:EhcacheShiroCache.java

示例10: putIfAbsent

import org.springframework.cache.support.SimpleValueWrapper; //导入依赖的package包/类
@Override
public ValueWrapper putIfAbsent(Object key, Object value) {
    if (value == null) {
        return new SimpleValueWrapper(null);
    }

    Object object = lookup(key);
    if (object != null) {
        return new SimpleValueWrapper(object);
    }

    put(key, value);
    return new SimpleValueWrapper(value);
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:15,代码来源:MemcachedCache.java

示例11: putIfAbsent

import org.springframework.cache.support.SimpleValueWrapper; //导入依赖的package包/类
@Override
public ValueWrapper putIfAbsent(Object key, Object value) {
    if (value == null) {
        return new SimpleValueWrapper(null);
    }

    ValueWrapper wrapper = get(key);
    if (wrapper != null) {
        return wrapper;
    }

    put(key, value);
    return new SimpleValueWrapper(value);
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:15,代码来源:OscacheCache.java

示例12: getAndPutFail

import org.springframework.cache.support.SimpleValueWrapper; //导入依赖的package包/类
@Test
public void getAndPutFail() {
	UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on get");
	willThrow(exception).given(cache).get(0L);
	willThrow(exception).given(cache).put(0L, 0L); // Update of the cache will fail as well

	Object counter = this.simpleService.get(0L);

	willReturn(new SimpleValueWrapper(2L)).given(cache).get(0L);
	Object counter2 = this.simpleService.get(0L);
	Object counter3 = this.simpleService.get(0L);
	assertNotSame(counter, counter2);
	assertEquals(counter2, counter3);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:CacheErrorHandlerTests.java

示例13: get

import org.springframework.cache.support.SimpleValueWrapper; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public ValueWrapper get(final Object key) {
	return (ValueWrapper) redisTemplate.execute(new RedisCallback<ValueWrapper>() {

		public ValueWrapper doInRedis(RedisConnection connection) throws DataAccessException {
			waitForLock(connection);
			byte[] bs = connection.get(computeKey(key));
			Object value = redisTemplate.getValueSerializer() != null ? redisTemplate.getValueSerializer().deserialize(bs) : bs;
			return (bs == null ? null : new SimpleValueWrapper(value));
		}
	}, true);
}
 
开发者ID:panguixiang,项目名称:my-spring-cache-redis,代码行数:13,代码来源:MyRedisCache.java

示例14: putIfAbsent

import org.springframework.cache.support.SimpleValueWrapper; //导入依赖的package包/类
@Override
public ValueWrapper putIfAbsent(Object key, Object value) {
    checkNotNull(key, "null key is not allowed");
    checkArgument(key instanceof Serializable, "key must implements Serializable");
    checkNotNull(value, "null value is not allowed");
    checkArgument(value instanceof Serializable, "value must implements Serializable");
    Serializable existValue = get(key, Serializable.class);
    if (Objects.isNull(existValue)) {
        put(key, value);
        return null;
    } else {
        return new SimpleValueWrapper(existValue);
    }
}
 
开发者ID:srarcbrsent,项目名称:tc,代码行数:15,代码来源:TcCodisCache.java

示例15: get

import org.springframework.cache.support.SimpleValueWrapper; //导入依赖的package包/类
public Object get(Object key) throws CacheException {
    Object value = springCache.get(key);
    if (value instanceof SimpleValueWrapper) {
        return ((SimpleValueWrapper) value).get();
    }
    return value;
}
 
开发者ID:zjlywjh001,项目名称:PhrackCTF-Platform-Team,代码行数:8,代码来源:SpringCacheManagerWrapper.java


注:本文中的org.springframework.cache.support.SimpleValueWrapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。