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


Java ByteArrayCodec类代码示例

本文整理汇总了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));
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:15,代码来源:CommandArgsTest.java

示例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));
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:15,代码来源:CommandArgsTest.java

示例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));
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:15,代码来源:CommandArgsTest.java

示例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();
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:15,代码来源:CustomCodecTest.java

示例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());
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:9,代码来源:ByteCodecClusterTest.java

示例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());
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:9,代码来源:ByteCodecClusterTest.java

示例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());
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:9,代码来源:ByteCodecClusterTest.java

示例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];
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:9,代码来源:RedisClientBenchmark.java

示例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);
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:29,代码来源:ClusterDistributionChannelWriterBenchmark.java

示例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];
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:9,代码来源:RedisClusterClientBenchmark.java

示例11: buildRedisPubSubCommands

import com.lambdaworks.redis.codec.ByteArrayCodec; //导入依赖的package包/类
private static RedisPubSubCommands<byte[], byte[]> buildRedisPubSubCommands(RedisClient redisClient) {
    return redisClient.connectPubSub(new ByteArrayCodec()).sync();
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-redis,代码行数:4,代码来源:GELFRedisOutput.java

示例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();
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:7,代码来源:SentinelConnectionTest.java

示例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();
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:7,代码来源:SentinelConnectionTest.java


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