Metadata-Version: 1.1
Name: ring_redis
Version: 0.8.0
Summary: a lightweight, high available & extensible cache solution using redis
Home-page: https://github.com/luochen1990/ring_redis
Author: luo chen
Author-email: luochen1990@gmail.com
License: BSD
Description: RING REDIS
        ===
        
        what for:
        ---
        
        I want a lightweight, High Available & Extensible cache solution using redis, but nutcracker is too heavy for a system with only 2 application server and 2 redis instance. and there isnt a good enough implementation of consistant hash using pure python. so I wrote this. I used it in 2 project and they are running well till now when half a year passed. so I shared it for people who have the same requirement.
        
        features:
        ---
        
        - lightweight & pure python solution
        - O(log(slice_number)) time complexity for a hash calculation. (slice_number = k * node_number, k equal to 200 as default)
        - O(slice_number * log(slice_number)) time complexity for hash ring rebuilding.
        - use O(slice_number) memory space always.
        - only dict like operation supported.
        
        how to use:
        ---
        
        ```python
        
        ################### your redis configuration #####################
        
        REDIS_CONF = {
        	'group0' : {
        		'node0': {
        			'capacity': 50 * 1024 ** 2,
        			'connection': {
        				'host' : '192.168.230.45',
        				'port' : 15061,
        				'db': 0,
        				'socket_timeout': 5e-3,
        			},
        		},
        		'node1': {
        			'capacity': 50 * 1024 ** 2,
        			'connection': {
        				'host' : '192.168.230.46',
        				'port' : 15061,
        				'db': 0,
        				'socket_timeout': 5e-3,
        			},
        		},
        	},
        }
        
        ############################ useage ##############################
        
        from ring_redis import redis_dict
        
        
        test = redis_dict(REDIS_CONF['group0'], prefix='test.', expire=20)
        
        test['a'] = 'abc'
        test['bc'] = 'def'
        
        print("test['a'] : %s" % (test['a']))
        print("test['bc'] : %s" % (test['bc']))
        
        print("len(test) : %s" % (len(test)))
        print("test.keys() : %s" % (test.keys()))
        print("'a' in test? : %s" % ('a' in test))
        print("'b' in test? : %s" % ('b' in test))
        
        print("test.get_entry('x') : %s" % (test.get_entry('x')))
        print("test.total_hash(test.get_entry('x')) : %s" % (test.total_hash(test.get_entry('x'))))
        print("test.alive_hash(test.get_entry('x')) : %s" % (test.alive_hash(test.get_entry('x'))))
        
        ```
        
        
        
        
Keywords: redis,consistent hash,high available,HA,extensible,pure python
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
