// Path: src/main/java/com/officedrop/redis/failover/jedis/ClientFunction.java
// public interface ClientFunction <R> {
// 
//     public R apply( JedisClient client );
// 
// }
// 
// Path: src/main/java/com/officedrop/redis/failover/jedis/JedisClient.java
// public interface JedisClient extends BinaryJedisCommands, JedisActions {
// 
// }
// 
// Path: src/main/java/com/officedrop/redis/failover/jedis/JedisClientFactory.java
// public interface JedisClientFactory {
// 
//     public JedisClient create( HostConfiguration configuration  );
// 
// }
// 
// Path: src/main/java/com/officedrop/redis/failover/utils/CircularList.java
// public class CircularList<T> implements Iterable<T> {
// 
//     private final ReentrantLock lock = new ReentrantLock();
//     private final List<T> collection;
//     private int currentIndex;
// 
//     public CircularList(Collection<T> iterator) {
//         this.collection = new ArrayList<T>(iterator);
//     }
// 
//     public CircularList( T ... items ) {
//         this(Arrays.asList(items));
//     }
// 
//     public int getSize() {
//         return this.collection.size();
//     }
// 
//     public boolean isEmpty() {
//         return this.collection.size() == 0;
//     }
// 
//     public T next() {
// 
//         try {
//             this.lock.lock();
// 
//             T item = this.collection.get(this.currentIndex);
// 
//             if ( this.currentIndex >= (this.collection.size() - 1) ) {
//                 this.currentIndex = 0;
//             } else {
//                 this.currentIndex++;
//             }
// 
//             return item;
// 
//         } finally {
//             this.lock.unlock();
//         }
// 
//     }
// 
//     @Override
//     public Iterator<T> iterator() {
//         return this.collection.iterator();
//     }
// }


import com.officedrop.redis.failover.jedis.ClientFunction;
import com.officedrop.redis.failover.jedis.JedisClient;
import com.officedrop.redis.failover.jedis.JedisClientFactory;
import com.officedrop.redis.failover.utils.CircularList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.BinaryClient;
import redis.clients.jedis.SortingParams;
import redis.clients.jedis.Tuple;
import java.util.*;
        return this.doAction(ClientType.MASTER, new ClientFunction<String>() {
            @Override
            public String apply(JedisClient client) {
                return client.lset(key, index, value);
            }
        });
    }

    @Override
    public Long lrem(final String key, final long count, final String value) {
        return this.doAction(ClientType.MASTER, new ClientFunction<Long>() {
            @Override
            public Long apply(JedisClient client) {
                return client.lrem(key, count, value);
            }
        });
    }

    @Override
    public String lpop(final String key) {
        return this.doAction(ClientType.MASTER, new ClientFunction<String>() {
            @Override
            public String apply(JedisClient client) {
                return client.lpop(key);
            }
        });
    }

    @Override
    public String rpop(final String key) {
// Path: src/main/java/com/officedrop/redis/failover/jedis/ClientFunction.java
// public interface ClientFunction <R> {
// 
//     public R apply( JedisClient client );
// 
// }
// 
// Path: src/main/java/com/officedrop/redis/failover/jedis/JedisClient.java
// public interface JedisClient extends BinaryJedisCommands, JedisActions {
// 
// }
// 
// Path: src/main/java/com/officedrop/redis/failover/jedis/JedisClientFactory.java
// public interface JedisClientFactory {
// 
//     public JedisClient create( HostConfiguration configuration  );
// 
// }
// 
// Path: src/main/java/com/officedrop/redis/failover/utils/CircularList.java
// public class CircularList<T> implements Iterable<T> {
// 
//     private final ReentrantLock lock = new ReentrantLock();
//     private final List<T> collection;
//     private int currentIndex;
// 
//     public CircularList(Collection<T> iterator) {
//         this.collection = new ArrayList<T>(iterator);
//     }
// 
//     public CircularList( T ... items ) {
//         this(Arrays.asList(items));
//     }
// 
//     public int getSize() {
//         return this.collection.size();
//     }
// 
//     public boolean isEmpty() {
//         return this.collection.size() == 0;
//     }
// 
//     public T next() {
// 
//         try {
//             this.lock.lock();
// 
//             T item = this.collection.get(this.currentIndex);
// 
//             if ( this.currentIndex >= (this.collection.size() - 1) ) {
//                 this.currentIndex = 0;
//             } else {
//                 this.currentIndex++;
//             }
// 
//             return item;
// 
//         } finally {
//             this.lock.unlock();
//         }
// 
//     }
// 
//     @Override
//     public Iterator<T> iterator() {
//         return this.collection.iterator();
//     }
// }


// Path: src/main/java/com/officedrop/redis/failover/Client.java
import com.officedrop.redis.failover.jedis.ClientFunction;
import com.officedrop.redis.failover.jedis.JedisClient;
import com.officedrop.redis.failover.jedis.JedisClientFactory;
import com.officedrop.redis.failover.utils.CircularList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.BinaryClient;
import redis.clients.jedis.SortingParams;
import redis.clients.jedis.Tuple;
import java.util.*;

        return this.doAction(ClientType.MASTER, new ClientFunction<String>() {
            @Override
            public String apply(JedisClient client) {
                return client.lset(key, index, value);
            }
        });
    }

    @Override
    public Long lrem(final String key, final long count, final String value) {
        return this.doAction(ClientType.MASTER, new ClientFunction<Long>() {
            @Override
            public Long apply(JedisClient client) {
                return client.lrem(key, count, value);
            }
        });
    }

    @Override
    public String lpop(final String key) {
        return this.doAction(ClientType.MASTER, new ClientFunction<String>() {
            @Override
            public String apply(JedisClient client) {
                return client.lpop(key);
            }
        });
    }

    @Override
    public String rpop(final String key) {
        return this.doAction(ClientType.MASTER, new ClientFunction<String>() {