All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.lontime.extredisson.provider.RedissonRxProvider Maven / Gradle / Ivy

The newest version!
package com.github.lontime.extredisson.provider;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import com.github.lontime.extredisson.codec.StringBytesMapCodec;
import com.github.lontime.shaded.org.redisson.api.RBucketRx;
import com.github.lontime.shaded.org.redisson.api.RStreamRx;
import com.github.lontime.shaded.org.redisson.api.RedissonRxClient;
import com.github.lontime.shaded.org.redisson.client.codec.Codec;

import static com.github.lontime.base.commonj.constants.Consts.DEFAULT_OBJECT_NAME;

/**
 * RedissonProvider.
 * @author lontime
 * @since 1.0
 */
public interface RedissonRxProvider extends RedissonProvider {

    /**
     * getClient.
     * @return Redisson client
     */
    default RedissonRxClient clientRx() {
        return clientRx(DEFAULT_OBJECT_NAME);
    }


    /**
     * getClient.
     * start with '@@' is fixed name
     * @param name name
     * @return Redisson client
     */
    default RedissonRxClient clientRx(String name) {
        return clientRx(Collections.singletonList(name));
    }

    /**
     * getClient.
     * @param name1 name
     * @param name2 name2
     * @return Redisson client
     */
    default RedissonRxClient clientRx(String name1, String name2) {
        return clientRx(Arrays.asList(name1, name2));
    }

    /**
     * clientRx.
     * @param names names
     * @return Redisson client
     */
    RedissonRxClient clientRx(List names);

    /**
     * directClientRx.
     * @param name name
     * @return Redisson client
     */
    RedissonRxClient directClientRx(String name);


    /**
     * getRxBucket.
     * @param name name
     * @param  V
     * @return RBucketReactive
     */
    default  RBucketRx getBucketRx(String name) {
        return getBucketRx(name, null);
    }

    /**
     * getRxBucket.
     * @param name name
     * @param codec codec
     * @param  V
     * @return RBucketReactive
     */
    default  RBucketRx getBucketRx(String name, Codec codec) {
        final String actualName = resolve(name);
        if (codec == null) {
            return clientRx(name).getBucket(actualName);
        }
        return clientRx(name).getBucket(actualName, codec);
    }

    /**
     * getStream.
     * @param name name
     * @param  V
     * @param  K
     * @return RBucketReactive
     */
    default  RStreamRx getStreamRx(String name) {
        return getStreamRx(name, null);
    }

    /**
     * getStream.
     * @param name name
     * @param  V
     * @param  K
     * @return RBucketReactive
     */
    default  RStreamRx getBytesStreamRx(String name) {
        return getStreamRx(name, StringBytesMapCodec.INSTANCE);
    }

    /**
     * getStream.
     * @param name name
     * @param codec codec
     * @param  V
     * @param  K
     * @return RBucketReactive
     */
    default  RStreamRx getStreamRx(String name, Codec codec) {
        final String actualName = resolve(name);
        if (codec == null) {
            return clientRx(name).getStream(actualName);
        }
        return clientRx(name).getStream(actualName, codec);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy