Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Setup normal class to mobio lru cache

Project description

LRU Cache

Thư viện caching của MOBIO. Hỗ trợ cache trên memory hoặc Redis.

Cài đặt:

pip3 install m-caching

Sử dụng:

__store_type = StoreType.REDIS # for redis cache
__store_type = StoreType.LOCAL # for memory cache
__file_config = 'config-file-path'

lru_cache = LruCache(store_type=__store_type, config_file_name=__file_config)

Ignore empty values from cache

__store_type = StoreType.REDIS
__file_config = 'config-file-path'
lru_cache = LruCache(store_type=__store_type, config_file_name=__file_config)
lru_cache.accept_none(False) # => ignore none values


cache for class's function

class TestCache:
    def test(self, x):
        print("TestCache::test param %s" % x)
        return x + 1

    def test_static(x):
        print("TestCache::test_static test param %s" % x)
        return x + 1

cache for normal function

def some_expensive_method(x):
    print("Calling some_expensive_method(" + str(x) + ")")
    return x + 200

Example config


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for m-caching, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size m_caching-0.1.2-py3-none-any.whl (6.3 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size m-caching-0.1.2.tar.gz (5.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page