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 }; 042 043 <T> T execute(RedisCallable<T> call) throws JedisException; 044 045 Pool<Jedis> getPool(); 046 047 /** 048 * Start to trace Redis activity only for debug purpose. 049 * @since 8.1 050 */ 051 default void startMonitor() { 052 } 053 054 /** 055 * Stop tracing Redis activity. 056 * @since 8.1 057 */ 058 default void stopMonitor() { 059 } 060 061}