gpt4 book ai didi

caching - Grails cache-redis version 1.1.0 插件编译报错

转载 作者:可可西里 更新时间:2023-11-01 11:17:05 24 4
gpt4 key购买 nike

我将 cache-redis 插件添加到我的 Grails 2.5.1 应用程序,但编译失败。类 GrailsRedisCache 没有实现来自接口(interface) org.springframework.cache.Cache 的方法 Cache.ValueWrapper putIfAbsent(Object var1, Object var2)。 Grails 2.5.1 和 Cache 1.1.8 插件是否有新的 Redis 缓存插件?

BuildConfig.groovy编译':缓存:1.1.8'编译“org.grails.plugins:cache-redis:1.1.0”

.../plugins/cache-redis-1.1.0/src/java/grails/plugin/cache/redis/GrailsRedisCache.java:39: error: GrailsRedisCache is not abstract and does not override abstract method putIfAbsent(Object,Object) in Cache

putIfAbsent 方法的可能实现。

@Override
public ValueWrapper putIfAbsent(Object o, Object o1) {
ValueWrapper val = get(o);

if (null != val) {
return val;
}

put(o, o1);
return get(o);
}

在 GitHub 上 putIfAbsent()方法实现。不确定为什么插件没有在 Grails.org 上发布.

@SuppressWarnings("unchecked")
@Override
public ValueWrapper putIfAbsent(final Object key, final Object value) {
final byte[] k = computeKey(key);
return (ValueWrapper) template.execute(new RedisCallback<ValueWrapper>() {
public ValueWrapper doInRedis(RedisConnection connection) throws DataAccessException {
waitForLock(connection);
byte[] bs = connection.get(computeKey(key));

if (bs == null) {
connection.multi();
connection.set(k, template.getValueSerializer().serialize(value));
connection.zAdd(setName, 0, k);

// Set key time to live when expiration has been configured.
if (ttl > NEVER_EXPIRE) {
connection.expire(k, ttl);
connection.expire(setName, ttl);
}

connection.exec();
}

bs = connection.get(computeKey(key));
return (bs == null ? null : newValueWrapper(template.getValueSerializer().deserialize(bs)));
}
}, true);
}

最佳答案

cache-redis 版本 1.1.2-SNAPSHOT 已经发布并解决了这个问题。

编译':cache-redis:1.1.2-SNAPSHOT'

关于caching - Grails cache-redis version 1.1.0 插件编译报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45090152/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com