com.lambdaworks.redis.codec.RedisCodec Java Examples

The following examples show how to use com.lambdaworks.redis.codec.RedisCodec. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QueueListenerFactory.java    From spinach with Apache License 2.0 6 votes vote down vote up
/**
 * @param disqueClient a shared client instance. Creates a new client instance if {@literal null}
 * @param scheduler the scheduler for blocking operations, must not be {@literal null}
 * @param disqueURI the URI, must not be {@literal null}
 * @param codec use this codec to encode/decode keys and values, must not be {@literal null}
 * @param queues queue names to listen on, must not be {@literal null} and not empty
 */
protected QueueListenerFactory(DisqueClient disqueClient, Scheduler scheduler, DisqueURI disqueURI, RedisCodec<K, V> codec,
        K[] queues) {

    LettuceAssert.notNull(scheduler, "Scheduler must not be null");
    LettuceAssert.notNull(disqueURI, "DisqueURI must not be null");
    LettuceAssert.notNull(codec, "RedisCodec must not be null");
    LettuceAssert.isTrue(queues != null && queues.length > 0, "Queues must not be empty");

    if (disqueClient != null) {
        sharedClient = true;
        this.disqueClient = disqueClient;
    } else {
        sharedClient = false;
        this.disqueClient = DisqueClient.create();
    }
    this.disqueURI = disqueURI;
    this.codec = codec;
    this.queues = queues;
    this.scheduler = scheduler;
}
 
Example #2
Source File: RedisCacheServiceBuilder.java    From registry with Apache License 2.0 5 votes vote down vote up
private RedisCodec getRedisCodec() {
    final String codec = cacheConfig.getCacheEntry().getCodec();
    if (codec != null) {
        return new Utf8StringCodec();
    } else {
        try {
            return ReflectionHelper.newInstance(codec);
        } catch (Exception e) {
            throw new RuntimeException("Exception occurred creating codec", e);
        }
    }
}
 
Example #3
Source File: RedisCacheServiceBuilder.java    From streamline with Apache License 2.0 5 votes vote down vote up
private RedisCodec getRedisCodec() {
    final String codec = cacheConfig.getCacheEntry().getCodec();
    if (codec != null) {
        return new Utf8StringCodec();
    } else {
        try {
            return ReflectionHelper.newInstance(codec);
        } catch (Exception e) {
            throw new RuntimeException("Exception occurred creating codec", e);
        }
    }
}
 
Example #4
Source File: AbstractRedisConnectionFactory.java    From streamline with Apache License 2.0 4 votes vote down vote up
public RedisCodec<K, V> getCodec() {
    return codec;
}
 
Example #5
Source File: AbstractRedisConnectionFactory.java    From streamline with Apache License 2.0 4 votes vote down vote up
public AbstractRedisConnectionFactory(RedisClient redisClient, RedisCodec<K, V> codec) {
    this.redisClient = redisClient;
    this.codec = codec;
}
 
Example #6
Source File: RedisConnectionFactory.java    From streamline with Apache License 2.0 4 votes vote down vote up
public RedisConnectionFactory(RedisClient redisClient, RedisCodec<K, V> codec) {
    super(redisClient, codec);
}
 
Example #7
Source File: RedisConnectionPoolFactory.java    From streamline with Apache License 2.0 4 votes vote down vote up
public RedisConnectionPoolFactory(RedisClient redisClient, RedisCodec<K, V> codec) {
    this(redisClient, codec, MAX_IDLE, MAX_ACTIVE);
}
 
Example #8
Source File: RedisConnectionPoolFactory.java    From streamline with Apache License 2.0 4 votes vote down vote up
public RedisConnectionPoolFactory(RedisClient redisClient, RedisCodec<K, V> codec, int maxIdle, int maxActive) {
    super(redisClient, codec);
    this.maxIdle = maxIdle;
    this.maxActive = maxActive;
}
 
Example #9
Source File: DisqueCommandArgs.java    From spinach with Apache License 2.0 4 votes vote down vote up
public DisqueCommandArgs(RedisCodec<K, V> codec) {
    super(codec);
}
 
Example #10
Source File: DisqueCommandBuilder.java    From spinach with Apache License 2.0 4 votes vote down vote up
public DisqueCommandBuilder(RedisCodec<K, V> codec) {
    super(codec);
}
 
Example #11
Source File: BaseCommandBuilder.java    From spinach with Apache License 2.0 4 votes vote down vote up
public BaseCommandBuilder(RedisCodec<K, V> codec) {
    this.codec = codec;
}
 
Example #12
Source File: DisqueClient.java    From spinach with Apache License 2.0 4 votes vote down vote up
protected <K, V> DisqueConnectionImpl<K, V> newDisquelAsyncConnectionImpl(CommandHandler<K, V> commandHandler,
        RedisCodec<K, V> codec, long timeout, TimeUnit unit) {
    return new DisqueConnectionImpl<K, V>(commandHandler, codec, timeout, unit);
}
 
Example #13
Source File: RedisConnectionPoolFactory.java    From registry with Apache License 2.0 4 votes vote down vote up
public RedisConnectionPoolFactory(RedisClient redisClient, RedisCodec<K, V> codec, int maxIdle, int maxActive) {
    super(redisClient, codec);
    this.maxIdle = maxIdle;
    this.maxActive = maxActive;
}
 
Example #14
Source File: RedisConnectionPoolFactory.java    From registry with Apache License 2.0 4 votes vote down vote up
public RedisConnectionPoolFactory(RedisClient redisClient, RedisCodec<K, V> codec) {
    this(redisClient, codec, MAX_IDLE, MAX_ACTIVE);
}
 
Example #15
Source File: StringScanOutput.java    From spinach with Apache License 2.0 4 votes vote down vote up
public StringScanOutput(RedisCodec<K, V> codec) {
    super(codec, new KeyScanCursor<String>());
}
 
Example #16
Source File: RedisConnectionFactory.java    From registry with Apache License 2.0 4 votes vote down vote up
public RedisConnectionFactory(RedisClient redisClient, RedisCodec<K, V> codec) {
    super(redisClient, codec);
}
 
Example #17
Source File: AbstractRedisConnectionFactory.java    From registry with Apache License 2.0 4 votes vote down vote up
public AbstractRedisConnectionFactory(RedisClient redisClient, RedisCodec<K, V> codec) {
    this.redisClient = redisClient;
    this.codec = codec;
}
 
Example #18
Source File: AbstractRedisConnectionFactory.java    From registry with Apache License 2.0 4 votes vote down vote up
public RedisCodec<K, V> getCodec() {
    return codec;
}
 
Example #19
Source File: JobListOutput.java    From spinach with Apache License 2.0 4 votes vote down vote up
public JobListOutput(RedisCodec<K, V> codec, K defaultQueue) {
    super(codec, new ArrayList<Job<K, V>>());
    this.defaultQueue = defaultQueue;
}
 
Example #20
Source File: JobOutput.java    From spinach with Apache License 2.0 4 votes vote down vote up
public JobOutput(RedisCodec<K, V> codec) {
    super(codec, null);
}
 
Example #21
Source File: JobListOutput.java    From spinach with Apache License 2.0 4 votes vote down vote up
public JobListOutput(RedisCodec<K, V> codec) {
    super(codec, new ArrayList<Job<K, V>>());
}
 
Example #22
Source File: QstatMapOutput.java    From spinach with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("rawtypes")
public QstatMapOutput(RedisCodec<K, V> codec) {
    super(codec, new HashMap<String, Object>());
    stack = new LinkedList<List<Object>>();
    depth = 0;
}
 
Example #23
Source File: DisqueClient.java    From spinach with Apache License 2.0 3 votes vote down vote up
/**
 * Open a new connection to a Disque server using the supplied {@link DisqueURI} and the supplied {@link RedisCodec codec}
 * to encode/decode keys. Command timeouts are applied from the given {@link DisqueURI#getTimeout()} settings.
 *
 * @param codec use this codec to encode/decode keys and values, must not be {@literal null}
 * @param disqueURI the Disque server to connect to, must not be {@literal null}
 * @param socketAddressSupplierFactory factory for {@link SocketAddress} for connecting to Disque based on multiple
 *        connection points.
 * @param <K> Key type.
 * @param <V> Value type.
 * 
 * @return A new connection.
 */
public <K, V> DisqueConnection<K, V> connect(RedisCodec<K, V> codec, DisqueURI disqueURI,
        SocketAddressSupplierFactory socketAddressSupplierFactory) {

    assertNotNull(disqueURI);
    checkValidDisqueURI(disqueURI);
    return connect0(codec, disqueURI, socketAddressSupplierFactory, disqueURI.getTimeout(), disqueURI.getUnit());
}
 
Example #24
Source File: DisqueConnectionImpl.java    From spinach with Apache License 2.0 2 votes vote down vote up
/**
 * Initialize a new connection.
 *
 * @param writer the channel writer
 * @param codec Codec used to encode/decode keys and values.
 * @param timeout Maximum time to wait for a response.
 * @param unit Unit of time for the timeout.
 */
public DisqueConnectionImpl(RedisChannelWriter<K, V> writer, RedisCodec<K, V> codec, long timeout, TimeUnit unit) {
    super(writer, timeout, unit);
    this.codec = codec;
}
 
Example #25
Source File: DisqueReactiveCommandsImpl.java    From spinach with Apache License 2.0 2 votes vote down vote up
/**
 * Initialize a new instance.
 *
 * @param connection the connection to operate on
 * @param codec the codec for command encoding
 */
public DisqueReactiveCommandsImpl(DisqueConnection<K, V> connection, RedisCodec<K, V> codec) {
    this.connection = connection;
    this.codec = codec;
    commandBuilder = new DisqueCommandBuilder<K, V>(codec);
}
 
Example #26
Source File: DisqueAsyncCommandsImpl.java    From spinach with Apache License 2.0 2 votes vote down vote up
/**
 * Initialize a new instance.
 *
 * @param connection the connection to operate on
 * @param codec the codec for command encoding
 */
public DisqueAsyncCommandsImpl(DisqueConnection<K, V> connection, RedisCodec<K, V> codec) {
    this.connection = connection;
    this.codec = codec;
    commandBuilder = new DisqueCommandBuilder<K, V>(codec);
}
 
Example #27
Source File: QueueListenerFactory.java    From spinach with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new {@link QueueListenerFactory}. The provided {@code scheduler} is used for listener notification and I/O
 * operations.
 *
 * @param disqueClient a shared client instance for reuse
 * @param scheduler a scheduler from rxjava for I/O operations, must not be {@literal null}
 * @param disqueURI the DisqueURI
 * @param codec use this codec to encode/decode keys and values, must note be {@literal null}
 * @param queues the queue names
 * @param <K> Key type
 * @param <V> Value type
 * @return a new instance of {@link QueueListenerFactory}
 */
public static <K, V> QueueListenerFactory<K, V> create(DisqueClient disqueClient, Scheduler scheduler, DisqueURI disqueURI,
        RedisCodec<K, V> codec, K... queues) {
    return new QueueListenerFactory<K, V>(disqueClient, scheduler, disqueURI, codec, queues);
}
 
Example #28
Source File: QueueListenerFactory.java    From spinach with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new {@link QueueListenerFactory}. The provided {@code scheduler} is used for listener notification and I/O
 * operations.
 *
 * @param scheduler a scheduler from rxjava for I/O operations
 * @param disqueURI the DisqueURI
 * @param codec use this codec to encode/decode keys and values, must note be {@literal null}
 * @param queues the queue names
 * @param <K> Key type
 * @param <V> Value type
 * @return a new instance of {@link QueueListenerFactory}
 */
public static <K, V> QueueListenerFactory<K, V> create(Scheduler scheduler, DisqueURI disqueURI, RedisCodec<K, V> codec,
        K... queues) {
    return new QueueListenerFactory<K, V>(scheduler, disqueURI, codec, queues);
}
 
Example #29
Source File: QueueListenerFactory.java    From spinach with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new {@link QueueListenerFactory}. The default {@link Schedulers#io()} scheduler is used for listener
 * notification and I/O operations.
 *
 * @param disqueURI the DisqueURI
 * @param codec use this codec to encode/decode keys and values, must note be {@literal null}
 * @param queues the queue names
 * @param <K> Key type
 * @param <V> Value type
 * @return a new instance of {@link QueueListenerFactory}
 */
public static <K, V> QueueListenerFactory<K, V> create(DisqueURI disqueURI, RedisCodec<K, V> codec, K... queues) {
    return new QueueListenerFactory<K, V>(Schedulers.io(), disqueURI, codec, queues);
}
 
Example #30
Source File: QueueListenerFactory.java    From spinach with Apache License 2.0 2 votes vote down vote up
/**
 * @param scheduler the scheduler for blocking operations, must not be {@literal null}
 * @param disqueURI the URI, must not be {@literal null}
 * @param codec use this codec to encode/decode keys and values, must not be {@literal null}
 * @param queues queue names to listen on, must not be {@literal null} and not empty
 */
protected QueueListenerFactory(Scheduler scheduler, DisqueURI disqueURI, RedisCodec<K, V> codec, K[] queues) {
    this(null, scheduler, disqueURI, codec, queues);
}