Class RedisInterceptor

  • All Implemented Interfaces:
    okhttp3.Interceptor

    public class RedisInterceptor
    extends Object
    implements okhttp3.Interceptor
    • Constructor Detail

      • RedisInterceptor

        public RedisInterceptor​(redis.clients.jedis.JedisShardInfo info,
                                int ttl)
      • RedisInterceptor

        public RedisInterceptor​(redis.clients.jedis.Jedis jedis,
                                int ttl)
    • Method Detail

      • intercept

        public okhttp3.Response intercept​(okhttp3.Interceptor.Chain chain)
                                   throws IOException
        Specified by:
        intercept in interface okhttp3.Interceptor
        Throws:
        IOException
      • beforeRequest

        public okhttp3.Response beforeRequest​(okhttp3.Request request)
                                       throws IOException
        Check Redis if it has cached a response for this request already. Does nothing for non-GET requests.
        Parameters:
        request - The request that was executed.
        Returns:
        The response if a response is applicable.
        Throws:
        IOException
      • afterResponse

        public okhttp3.Response afterResponse​(okhttp3.Request request,
                                              okhttp3.Response response)
                                       throws IOException
        Throws:
        IOException
      • getJedis

        public redis.clients.jedis.Jedis getJedis()