Skip to content

InfinityMod/easyRedisCache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Easy Redis caching decorators

Redis cache implementation for redis caching with multithread/multitask secured thread.

Requirements

Library was tested in the following environments:

  • Python 2.7

Feel free to try it in yours, but it's not guaranteed it will work. Submit an issue if you think it should.

Installation

pip install git+https://github.com/InfinityMod/sherlock
pip install easyRedisCache

Introduction

Different ways to cache something

# classic way
from easyRedisCache import easyRedisCache

eC = easyRedisCache("keyCache")

import threading
import time

def worker():
    print "Worker 1 Init"
    with eC.setBlocking("key", get=True) as block:
        if block.exception == None:
            #print "Worker 1 Set"
            print block.val
            block.val += "foo"
            time.sleep(1)

def worker2():
    print "Worker 2 Init"
    with eC.setBlocking("key", get=True) as block:
        if block.exception == None:
            #print "Worker 2 Set"
            print block.val
            block.val += "bar"


eC.set("key", "co")

threads = []
for i in range(5):
    t = threading.Thread(target=worker)
    threads.append(t)
    t.start()

for i in range(5):
    t = threading.Thread(target=worker2)
    threads.append(t)
    t.start()

About

Easy Redis Cache for Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages