本文整理汇总了Java中com.lambdaworks.redis.codec.ByteArrayCodec类的典型用法代码示例。如果您正苦于以下问题:Java ByteArrayCodec类的具体用法?Java ByteArrayCodec怎么用?Java ByteArrayCodec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ByteArrayCodec类属于com.lambdaworks.redis.codec包,在下文中一共展示了ByteArrayCodec类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addByteUsingByteCodec
import com.lambdaworks.redis.codec.ByteArrayCodec; //导入依赖的package包/类
@Test
public void addByteUsingByteCodec() {
CommandArgs<byte[], byte[]> args = new CommandArgs<>(ByteArrayCodec.INSTANCE)
.add("one".getBytes());
ByteBuf buffer = Unpooled.buffer();
args.encode(buffer);
ByteBuf expected = Unpooled.buffer();
expected.writeBytes(("$3\r\n" + "one\r\n").getBytes());
assertThat(buffer.toString(LettuceCharsets.ASCII)).isEqualTo(expected.toString(LettuceCharsets.ASCII));
}
示例2: addValueUsingByteCodec
import com.lambdaworks.redis.codec.ByteArrayCodec; //导入依赖的package包/类
@Test
public void addValueUsingByteCodec() {
CommandArgs<byte[], byte[]> args = new CommandArgs<>(ByteArrayCodec.INSTANCE)
.addValue("one".getBytes());
ByteBuf buffer = Unpooled.buffer();
args.encode(buffer);
ByteBuf expected = Unpooled.buffer();
expected.writeBytes(("$3\r\n" + "one\r\n").getBytes());
assertThat(buffer.toString(LettuceCharsets.ASCII)).isEqualTo(expected.toString(LettuceCharsets.ASCII));
}
示例3: addKeyUsingByteCodec
import com.lambdaworks.redis.codec.ByteArrayCodec; //导入依赖的package包/类
@Test
public void addKeyUsingByteCodec() {
CommandArgs<byte[], byte[]> args = new CommandArgs<>(ByteArrayCodec.INSTANCE)
.addValue("one".getBytes());
ByteBuf buffer = Unpooled.buffer();
args.encode(buffer);
ByteBuf expected = Unpooled.buffer();
expected.writeBytes(("$3\r\n" + "one\r\n").getBytes());
assertThat(buffer.toString(LettuceCharsets.ASCII)).isEqualTo(expected.toString(LettuceCharsets.ASCII));
}
示例4: testByteCodec
import com.lambdaworks.redis.codec.ByteArrayCodec; //导入依赖的package包/类
@Test
public void testByteCodec() throws Exception {
RedisCommands<byte[], byte[]> connection = client.connect(new ByteArrayCodec()).sync();
String value = "üöäü+#";
connection.set(key.getBytes(), value.getBytes());
assertThat(connection.get(key.getBytes())).isEqualTo(value.getBytes());
connection.set(key.getBytes(), null);
assertThat(connection.get(key.getBytes())).isEqualTo(new byte[0]);
List<byte[]> keys = connection.keys(key.getBytes());
assertThat(keys).contains(key.getBytes());
connection.close();
}
示例5: testByteCodec
import com.lambdaworks.redis.codec.ByteArrayCodec; //导入依赖的package包/类
@Test
public void testByteCodec() throws Exception {
StatefulRedisClusterConnection<byte[], byte[]> connection = clusterClient.connect(new ByteArrayCodec());
connection.sync().set(key.getBytes(), value.getBytes());
assertThat(connection.sync().get(key.getBytes())).isEqualTo(value.getBytes());
}
示例6: deprecatedTestByteCodec
import com.lambdaworks.redis.codec.ByteArrayCodec; //导入依赖的package包/类
@Test
public void deprecatedTestByteCodec() throws Exception {
RedisAdvancedClusterCommands<byte[], byte[]> commands = clusterClient.connectCluster(new ByteArrayCodec());
commands.set(key.getBytes(), value.getBytes());
assertThat(commands.get(key.getBytes())).isEqualTo(value.getBytes());
}
示例7: deprecatedTestAsyncByteCodec
import com.lambdaworks.redis.codec.ByteArrayCodec; //导入依赖的package包/类
@Test
public void deprecatedTestAsyncByteCodec() throws Exception {
RedisAdvancedClusterAsyncCommands<byte[], byte[]> commands = clusterClient.connectClusterAsync(new ByteArrayCodec());
commands.set(key.getBytes(), value.getBytes()).get();
assertThat(commands.get(key.getBytes()).get()).isEqualTo(value.getBytes());
}
示例8: setup
import com.lambdaworks.redis.codec.ByteArrayCodec; //导入依赖的package包/类
@Setup
public void setup() {
redisClient = RedisClient.create(RedisURI.create(TestSettings.host(), TestSettings.port()));
connection = redisClient.connect(ByteArrayCodec.INSTANCE);
commands = new RedisFuture[BATCH_SIZE];
observables = new Observable[BATCH_SIZE];
}
示例9: setup
import com.lambdaworks.redis.codec.ByteArrayCodec; //导入依赖的package包/类
@Setup
@SuppressWarnings({ "unchecked", "rawrypes" })
public void setup() {
writer = new ClusterDistributionChannelWriter(CLIENT_OPTIONS, EMPTY_WRITER, ClusterEventListener.NO_OP);
Partitions partitions = new Partitions();
partitions.add(new RedisClusterNode(RedisURI.create("localhost", 1), "1", true, null, 0, 0, 0, IntStream.range(0, 8191)
.boxed().collect(Collectors.toList()), new HashSet<>()));
partitions.add(new RedisClusterNode(RedisURI.create("localhost", 2), "2", true, null, 0, 0, 0, IntStream
.range(8192, SlotHash.SLOT_COUNT).boxed().collect(Collectors.toList()), new HashSet<>()));
partitions.updateCache();
CompletableFuture<EmptyStatefulRedisConnection> connectionFuture = CompletableFuture.completedFuture(CONNECTION);
writer.setPartitions(partitions);
writer.setClusterConnectionProvider(new PooledClusterConnectionProvider(new EmptyRedisClusterClient(RedisURI.create(
"localhost", 7379)), EMPTY_WRITER, ByteArrayCodec.INSTANCE) {
@Override
public CompletableFuture getConnectionAsync(Intent intent, int slot) {
return connectionFuture;
}
});
writer.setPartitions(partitions);
}
示例10: setup
import com.lambdaworks.redis.codec.ByteArrayCodec; //导入依赖的package包/类
@Setup
public void setup() {
redisClusterClient = RedisClusterClient.create(RedisURI.create(TestSettings.host(), TestSettings.port(900)));
connection = redisClusterClient.connect(ByteArrayCodec.INSTANCE);
commands = new RedisFuture[BATCH_SIZE];
observables = new Observable[BATCH_SIZE];
}
示例11: buildRedisPubSubCommands
import com.lambdaworks.redis.codec.ByteArrayCodec; //导入依赖的package包/类
private static RedisPubSubCommands<byte[], byte[]> buildRedisPubSubCommands(RedisClient redisClient) {
return redisClient.connectPubSub(new ByteArrayCodec()).sync();
}
示例12: connectWithByteCodec
import com.lambdaworks.redis.codec.ByteArrayCodec; //导入依赖的package包/类
@Test
public void connectWithByteCodec() throws Exception {
RedisSentinelCommands<byte[], byte[]> connection = sentinelClient.connectSentinel(new ByteArrayCodec()).sync();
assertThat(connection.master(MASTER_ID.getBytes())).isNotNull();
connection.close();
}
示例13: deprecatedConnectWithByteCodec
import com.lambdaworks.redis.codec.ByteArrayCodec; //导入依赖的package包/类
@Test
public void deprecatedConnectWithByteCodec() throws Exception {
RedisSentinelAsyncCommands<byte[], byte[]> connection = sentinelClient.connectSentinelAsync(new ByteArrayCodec());
assertThat(connection.master(MASTER_ID.getBytes())).isNotNull();
connection.close();
}