001/* 002 * (C) Copyright 2006-2014 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.nuxeo.ecm.core.redis; 017 018import redis.clients.jedis.Jedis; 019import redis.clients.jedis.exceptions.JedisException; 020import redis.clients.util.Pool; 021 022/** 023 * Execute the jedis statement 024 * 025 * @since 6.0 026 */ 027public interface RedisExecutor { 028 029 public static final RedisExecutor NOOP = new RedisExecutor() { 030 031 @Override 032 public <T> T execute(RedisCallable<T> call) throws JedisException { 033 throw new UnsupportedOperationException("No redis executor available"); 034 } 035 036 @Override 037 public Pool<Jedis> getPool() { 038 throw new UnsupportedOperationException("No pool available"); 039 } 040 041 @Override 042 public boolean supportPipelined() { 043 return false; 044 } 045 046 }; 047 048 <T> T execute(RedisCallable<T> call) throws JedisException; 049 050 Pool<Jedis> getPool(); 051 052 /** 053 * Is the executor support pipelined operations 054 * @since 7.4 055 */ 056 boolean supportPipelined(); 057 058 /** 059 * Start to trace Redis activity only for debug purpose. 060 * @since 8.1 061 */ 062 default void startMonitor() { 063 } 064 065 /** 066 * Stop tracing Redis activity. 067 * @since 8.1 068 */ 069 default void stopMonitor() { 070 } 071 072}