001/*******************************************************************************
002 * Copyright (c) 2006-2014 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 ******************************************************************************/
009package org.nuxeo.ecm.core.redis;
010
011import redis.clients.jedis.Jedis;
012import redis.clients.jedis.exceptions.JedisException;
013import redis.clients.util.Pool;
014
015/**
016 * Execute the jedis statement
017 *
018 * @since 6.0
019 */
020public interface RedisExecutor {
021
022    public static final RedisExecutor NOOP = new RedisExecutor() {
023
024        @Override
025        public <T> T execute(RedisCallable<T> call) throws JedisException {
026            throw new UnsupportedOperationException("No redis executor available");
027        }
028
029        @Override
030        public Pool<Jedis> getPool() {
031            throw new UnsupportedOperationException("No pool available");
032        }
033
034        @Override
035        public boolean supportPipelined() {
036            return false;
037        }
038
039    };
040
041    <T> T execute(RedisCallable<T> call) throws JedisException;
042
043    Pool<Jedis> getPool();
044
045    /**
046     * Is the executor support pipelined operations
047     * @since 7.4
048     */
049    boolean supportPipelined();
050}