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

io.craft.atom.redis.DefaultMasterSlaveShardedRedis Maven / Gradle / Ivy

There is a newer version: 3.1.2
Show newest version
package io.craft.atom.redis;

import io.craft.atom.redis.api.MasterSlaveRedis;
import io.craft.atom.redis.api.MasterSlaveShardedRedis;
import io.craft.atom.redis.spi.Sharded;

import java.util.List;

import lombok.ToString;


/**
 * @author mindwind
 * @version 1.0, Jun 26, 2013
 */
@ToString(callSuper = true)
public class DefaultMasterSlaveShardedRedis extends AbstractShardedRedis implements MasterSlaveShardedRedis {


	public DefaultMasterSlaveShardedRedis(List shards) {
		this.sharded = new MasterSlaveRedisMurmurHashSharded(shards);
	}

	public DefaultMasterSlaveShardedRedis(Sharded sharded) {
		this.sharded = sharded;
	}
		
		
	// ~ ---------------------------------------------------------------------------------------------------------
	
	
	@Override
	public List shards() {
		return sharded.shards();
	}
	
	@Override
	public MasterSlaveRedis shard(String shardkey) {
		return sharded.shard(shardkey);
	}

	@Override
	public void enableReadSlave() {
		for (MasterSlaveRedis msr : shards()) {
			msr.enableReadSlave();
		}
	}
	
	@Override
	public void disableReadSlave() {
		for (MasterSlaveRedis msr : shards()) {
			msr.disableReadSlave();
		}
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy