本文整理了Java中org.redisson.config.Config.setCodec()
方法的一些代码示例,展示了Config.setCodec()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.setCodec()
方法的具体详情如下:
包路径:org.redisson.config.Config
类名称:Config
方法名:setCodec
[英]Redis key/value codec. Default is json-codec
[中]Redis键/值编解码器。默认为json编解码器
代码示例来源:origin: zhegexiaohuozi/SeimiCrawler
/**
* 如果开启分布式设置默认启用分布式队列
*/
public SeimiConfig(Config config) {
this.enableRedissonQueue = true;
this.redissonConfig = config;
this.redissonConfig.setCodec(new FstCodec());
}
代码示例来源:origin: redisson/redisson
protected RedissonClient buildClient() throws LifecycleException {
Config config = null;
try {
config = Config.fromJSON(new File(configPath), getClass().getClassLoader());
} catch (IOException e) {
// trying next format
try {
config = Config.fromYAML(new File(configPath), getClass().getClassLoader());
} catch (IOException e1) {
log.error("Can't parse json config " + configPath, e);
throw new LifecycleException("Can't parse yaml config " + configPath, e1);
}
}
try {
try {
Config c = new Config(config);
Codec codec = c.getCodec().getClass().getConstructor(ClassLoader.class)
.newInstance(Thread.currentThread().getContextClassLoader());
config.setCodec(codec);
} catch (Exception e) {
throw new IllegalStateException("Unable to initialize codec with ClassLoader parameter", e);
}
return Redisson.create(config);
} catch (Exception e) {
throw new LifecycleException(e);
}
}
代码示例来源:origin: killbill/killbill
@Override
public RedissonClient get() {
// JDK serialization codec for now, but we can do better in speed and space
final Codec codec = new SerializationCodec();
final Config redissonCfg = new Config();
redissonCfg.setCodec(codec)
.useSingleServer()
.setAddress(address)
.setConnectionMinimumIdleSize(connectionMinimumIdleSize);
return Redisson.create(redissonCfg);
}
}
代码示例来源:origin: redisson/redisson
oldConf.setCodec(new FstCodec());
setNettyThreads(oldConf.getNettyThreads());
setThreads(oldConf.getThreads());
setCodec(oldConf.getCodec());
setReferenceEnabled(oldConf.isReferenceEnabled());
setEventLoopGroup(oldConf.getEventLoopGroup());
代码示例来源:origin: redisson/redisson
oldConf.setCodec(new FstCodec());
setNettyThreads(oldConf.getNettyThreads());
setThreads(oldConf.getThreads());
setCodec(oldConf.getCodec());
setReferenceEnabled(oldConf.isReferenceEnabled());
setEventLoopGroup(oldConf.getEventLoopGroup());
代码示例来源:origin: debop/hibernate-redis
public static RedisClient createRedisClient(@NonNull final Config config) {
try {
if (config.getCodec() == null) {
config.setCodec(new SnappyCodec());
}
log.debug("Set Redisson Codec = {}", config.getCodec().getClass().getName());
RedissonClient redisson = Redisson.create(config);
return new RedisClient(redisson);
} catch (Exception e) {
log.error("Fail to create RedisClient.", e);
throw new RuntimeException(e);
}
}
代码示例来源:origin: debop/hibernate-redis
public static RedisClient createRedisClient(@NonNull final Config config) {
try {
if (config.getCodec() == null) {
config.setCodec(new SnappyCodec());
}
log.debug("Set Redisson Codec = {}", config.getCodec().getClass().getName());
RedissonClient redisson = Redisson.create(config);
return new RedisClient(redisson);
} catch (Exception e) {
log.error("Fail to create RedisClient.", e);
throw new RuntimeException(e);
}
}
代码示例来源:origin: com.github.debop/hibernate-redis
public static RedisClient createRedisClient(@NonNull final Config config) {
try {
if (config.getCodec() == null) {
config.setCodec(new SnappyCodec());
}
log.debug("Set Redisson Codec = {}", config.getCodec().getClass().getName());
RedissonClient redisson = Redisson.create(config);
return new RedisClient(redisson);
} catch (Exception e) {
log.error("Fail to create RedisClient.", e);
throw new RuntimeException(e);
}
}
代码示例来源:origin: debop/hibernate-redis
@PostConstruct
public void initialize() {
Config config = new Config();
ElasticacheServersConfig clusterConfig = config.useElasticacheServers();
clusterConfig.setScanInterval(2000);
clusterConfig.addNodeAddress(StringUtils.tokenizeToStringArray(redisNodes, ",", true, true));
config.setCodec(new SnappyCodec());
redisClient = Redisson.create(config);
}
代码示例来源:origin: jsimone/webapp-runner
.setConnectionMinimumIdleSize(commandLineParams.sessionStorePoolSize)
.setTimeout(commandLineParams.sessionStoreOperationTimout);
config.setCodec(new FstCodec());
代码示例来源:origin: org.kill-bill.billing/killbill-util
@Override
public RedissonClient get() {
// JDK serialization codec for now, but we can do better in speed and space
final Codec codec = new SerializationCodec();
final Config redissonCfg = new Config();
redissonCfg.setCodec(codec)
.useSingleServer()
.setAddress(address)
.setConnectionMinimumIdleSize(connectionMinimumIdleSize);
return Redisson.create(redissonCfg);
}
}
代码示例来源:origin: kekingcn/spring-boot-klock-starter
@Bean(destroyMethod = "shutdown")
@ConditionalOnMissingBean
RedissonClient redisson() throws Exception {
Config config = new Config();
if(klockConfig.getClusterServer()!=null){
config.useClusterServers().setPassword(klockConfig.getPassword())
.addNodeAddress(klockConfig.getClusterServer().getNodeAddresses());
}else {
config.useSingleServer().setAddress(klockConfig.getAddress())
.setDatabase(klockConfig.getDatabase())
.setPassword(klockConfig.getPassword());
}
Codec codec=(Codec) ClassUtils.forName(klockConfig.getCodec(),ClassUtils.getDefaultClassLoader()).newInstance();
config.setCodec(codec);
config.setEventLoopGroup(new NioEventLoopGroup());
return Redisson.create(config);
}
代码示例来源:origin: chexagon/redis-session-manager
@Override
protected final RedisSessionClient buildClient() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
Config config = new Config()
.setCodec(new ContextClassloaderSerializationCodec(getContainerClassLoader()))
.setTransportMode(isEpollSupported() ? TransportMode.EPOLL : TransportMode.NIO);
return new RedissonSessionClient(configure(config));
}
代码示例来源:origin: jzyong/game-server
/**
* 连接服务器
*
* @author JiangZhiYong
* @QQ 359135103 2017年9月15日 下午3:36:06
* @param configPath
*/
public static void connectRedis(String configPath) {
if (redisson != null) {
LOGGER.warn("Redisson客户端已经连接");
}
redissonClusterConfig = FileUtil.getConfigXML(configPath, "redissonClusterConfig.xml",
RedissonClusterConfig.class);
if (redissonClusterConfig == null) {
LOGGER.warn("{}/redissonClusterConfig.xml文件不存在", configPath);
System.exit(0);
}
Config config = new Config();
config.setCodec(new FastJsonCodec());
ClusterServersConfig clusterServersConfig = config.useClusterServers();
clusterServersConfig.setScanInterval(redissonClusterConfig.getScanInterval()); // 集群状态扫描间隔时间,单位是毫秒
// 可以用"rediss://"来启用SSL连接
redissonClusterConfig.getNodes().forEach(url -> clusterServersConfig.addNodeAddress(url));
clusterServersConfig.setReadMode(redissonClusterConfig.getReadMode());
clusterServersConfig.setSubscriptionMode(redissonClusterConfig.getSubscriptionMode());
redisson = Redisson.create(config);
}
代码示例来源:origin: org.redisson/redisson
oldConf.setCodec(new FstCodec());
setNettyThreads(oldConf.getNettyThreads());
setThreads(oldConf.getThreads());
setCodec(oldConf.getCodec());
setReferenceEnabled(oldConf.isReferenceEnabled());
setEventLoopGroup(oldConf.getEventLoopGroup());
内容来源于网络,如有侵权,请联系作者删除!