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

redis.clients.jedis.JedisSharding Maven / Gradle / Ivy

There is a newer version: 5.2.0
Show newest version
package redis.clients.jedis;

import java.util.List;
import java.util.regex.Pattern;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import redis.clients.jedis.providers.ShardedConnectionProvider;
import redis.clients.jedis.util.Hashing;

/**
 * @deprecated Sharding/Sharded feature will be removed in next major release.
 */
@Deprecated
public class JedisSharding extends UnifiedJedis {

  public static final Pattern DEFAULT_KEY_TAG_PATTERN = Pattern.compile("\\{(.+?)\\}");

  public JedisSharding(List shards) {
    this(new ShardedConnectionProvider(shards));
  }

  public JedisSharding(List shards, JedisClientConfig clientConfig) {
    this(new ShardedConnectionProvider(shards, clientConfig));
    setProtocol(clientConfig);
  }

  public JedisSharding(List shards, JedisClientConfig clientConfig,
      GenericObjectPoolConfig poolConfig) {
    this(new ShardedConnectionProvider(shards, clientConfig, poolConfig));
    setProtocol(clientConfig);
  }

  public JedisSharding(List shards, JedisClientConfig clientConfig, Hashing algo) {
    this(new ShardedConnectionProvider(shards, clientConfig, algo));
    setProtocol(clientConfig);
  }

  public JedisSharding(List shards, JedisClientConfig clientConfig,
      GenericObjectPoolConfig poolConfig, Hashing algo) {
    this(new ShardedConnectionProvider(shards, clientConfig, poolConfig, algo));
    setProtocol(clientConfig);
  }

  public JedisSharding(ShardedConnectionProvider provider) {
    super(provider);
  }

  public JedisSharding(ShardedConnectionProvider provider, Pattern tagPattern) {
    super(provider, tagPattern);
  }

  private void setProtocol(JedisClientConfig clientConfig) {
    RedisProtocol proto = clientConfig.getRedisProtocol();
    if (proto == RedisProtocol.RESP3) commandObjects.setProtocol(proto);
  }

  @Override
  public ShardedPipeline pipelined() {
    return new ShardedPipeline((ShardedConnectionProvider) provider);
  }

  /**
   * @return nothing
   * @throws UnsupportedOperationException
   */
  @Override
  public Transaction multi() {
    throw new UnsupportedOperationException();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy