我正在使用游戏版本2.6.2与来自karelcemus版本2.0.1 https://github.com/KarelCemus/play-redis的play-redis。根据文档,我已禁用play的默认EhCacheModule并启用play.api.cache.redis.RedisCacheModule
并在application.conf中绑定命名缓存,代码示例如下:
play.cache.bindCaches = ["db-cache", "user-cache", "session-cache", "options-cache"]
play {
modules {
enabled += "play.api.cache.redis.RedisCacheModule"
disabled += "play.api.cache.ehcache.EhCacheModule"
}
}
play.cache.redis {
bind-default = true
instances {
play {
host: localhost
port: 6379
prefix: default
}
options-cache{
host: localhost
port: 6379
prefix: options
}
}
}
我正在使用play.cache.SyncCacheApi
来实现缓存
import javax.inject.Inject;
import javax.inject.Singleton;
import play.cache.NamedCache;
import play.cache.SyncCacheApi;
@Singleton
public class GeneralOptions extends BaseOptions {
@Inject
public GeneralOptions(@NamedCache("options-cache") SyncCacheApi cache) {
super(cache);
}
}
在编译时我在运行时没有收到错误,错误即将到来
No implementation for play.cache.SyncCacheApi annotated with @play.cache.NamedCache(value=options-cache) was bound.
while locating play.cache.SyncCacheApi annotated with @play.cache.NamedCache(value=options-cache)
for the 1st parameter of GeneralOptions.<init>(GeneralOptions.java:25)
while locating GeneralOptions
所以每个类都在抛出使用命名缓存的错误。任何线索我都缺少什么配置? 。任何建议表示赞赏。
似乎作者使用@Named而不是@NamedCache,并且它既不是用play-redis-samples写的,也不用readme。