Git Product home page Git Product logo

redis-pipeline's Introduction

Appgree-Redis-Wrappers

These are classes used by Appgree to encapsulate and improve a Jedis client adding pipelining functionality, master-slave control, and a local in-memory cache to reduce the need for different threads to repeat reads. The classes can be used independently or nested.

License

The software stands under Apache 2 License and comes with NO WARRANTY

Features

  • RedisManager: singleton for Redis access.
  • RedisRemotePipelinedProvider: Send commands in a pipeline (independent thread pool) drastically improving throughput.
  • RedisCachedProvider: Store queried results in local cache so common access are already locally stored and need not be fetched.
  • RedisSentinelPool: Redis sentinel for high availability

TODOs

  • Not all Jedis methods are implemented but classes can be easily extended

Usage

All providers require a RedisRemoteBaseProvider or RedisRemotePipelinedProvider inside that contains a Jedis client or JedisPool.

   	JedisPoolConfig config = new JedisPoolConfig();
   	// set pool configuration...
   	
   	Set<String> sentinels = new HashSet<String>(); 
   	// add sentinels. Each sentinel is defined as "<host>:<port>", you can have as many as configured
   	
       // Check sentinels configuration
       RedisSentinelPool sentinelPool = null;
       if (sentinels != null && sentinels.size() > 0) {
           sentinelPool = new RedisSentinelPool(config, sentinels, poolTimeout);
       }

       // Initializes Redis Pipelines
       RedisPipelinedManager.staticInit(maxNPipelineChunk, maxNPipelinePerConn, pipelineMaxSyncTime, cachedErrorRetryDelay,
                       maxWaitTimeout, nThreadsCallback, maxBlockingPipelineTotal, traceDelay);

    	// create the RedisRemoteProvider, in this case, all are RedisRemotePipelinedProvider

       RedisRemotePipelinedProvider pipelinedProvider = new RedisRemotePipelinedProvider();
       RedisRemoteProvider noCachedProvider = new RedisRemoteProvider(cachedErrorRetryDelay);

       // Lets initialize jedis pool
       if (sentinelPool != null) {
           sentinelPool.init(host, pipelinedProvider);
           sentinelPool.init(host, noCachedProvider);
       } else {

           // Initializes independent providers
           JedisPool pool = new JedisPool(config, host, port, poolTimeout);
           pipelinedProvider.poolChanged(pool);
           noCachedProvider.poolChanged(pool);
       }
       
       // init inner provider
       ((RedisPipelinedManager)RedisPipelinedManager.getInstance()).init(pipelinedProvider, 0);

       // Initializes Redis Manager
       RedisProvider cachedProvider = new RedisCachedProvider(RedisPipelinedManager.getInstance(), maxTtl, maxElements);
       RedisManager.staticInit(cachedProvider);

       CacheKey.staticInit(defaultTtl);

Build

via Maven

redis-pipeline's People

Contributors

appgree avatar

Stargazers

Zero avatar Ven Ayya avatar J. David Requejo avatar  avatar

Watchers

Audrin Pereira avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.