All Projects β†’ duboviy β†’ Minicache

duboviy / Minicache

Licence: mit
πŸ“¦ Python memory caching utilities

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Minicache

Libmc
Fast and light-weight memcached client for C++ / #python / #golang #libmc
Stars: ✭ 429 (+443.04%)
Mutual labels:  cache, caching
Nebulex
In-memory and distributed caching toolkit for Elixir.
Stars: ✭ 662 (+737.97%)
Mutual labels:  cache, caching
Bigcache
Efficient cache for gigabytes of data written in Go.
Stars: ✭ 5,304 (+6613.92%)
Mutual labels:  cache, caching
Wp Rocket
Performance optimization plugin for WordPress
Stars: ✭ 394 (+398.73%)
Mutual labels:  cache, caching
Synchrotron
Caching layer load balancer.
Stars: ✭ 42 (-46.84%)
Mutual labels:  cache, caching
Stackexchange.redis.extensions
Stars: ✭ 419 (+430.38%)
Mutual labels:  cache, caching
Cashew
A simple and elegant yet powerful HTTP client cache for .NET
Stars: ✭ 70 (-11.39%)
Mutual labels:  cache, caching
Senparc.co2net
ζ”―ζŒ .NET Framework & .NET Core ηš„ε…¬ε…±εŸΊη‘€ζ‰©ε±•εΊ“
Stars: ✭ 289 (+265.82%)
Mutual labels:  utility, cache
Python Common Cache
This project is a cache component based on the memory and it is lightweight, simple and customizable. 🐍 πŸ˜ƒ
Stars: ✭ 21 (-73.42%)
Mutual labels:  utility, cache
Rw File Cache
πŸ—„οΈ PHP File-based Caching Library
Stars: ✭ 10 (-87.34%)
Mutual labels:  cache, caching
Memento
Memento is a development-only tool that caches HTTP calls once they have been executed.
Stars: ✭ 380 (+381.01%)
Mutual labels:  cache, caching
Fastcache
Fast thread-safe inmemory cache for big number of entries in Go. Minimizes GC overhead
Stars: ✭ 1,051 (+1230.38%)
Mutual labels:  cache, caching
Cachier
Persistent, stale-free, local and cross-machine caching for Python functions.
Stars: ✭ 359 (+354.43%)
Mutual labels:  cache, caching
Lada Cache
A Redis based, fully automated and scalable database cache layer for Laravel
Stars: ✭ 424 (+436.71%)
Mutual labels:  cache, caching
Cache
The Cache component provides an extended PSR-6 implementation for adding cache to your applications.
Stars: ✭ 3,606 (+4464.56%)
Mutual labels:  cache, caching
Cached
Rust cache structures and easy function memoization
Stars: ✭ 530 (+570.89%)
Mutual labels:  cache, caching
lambda-cache
Python utility for caching in Lambda Functions
Stars: ✭ 28 (-64.56%)
Mutual labels:  caching, cache
Scrapbook
PHP cache library, with adapters for e.g. Memcached, Redis, Couchbase, APC(u), SQL and additional capabilities (e.g. transactions, stampede protection) built on top.
Stars: ✭ 279 (+253.16%)
Mutual labels:  cache, caching
Cache Service Provider
A Cache Service Provider for Silex, using the doctrine/cache package
Stars: ✭ 23 (-70.89%)
Mutual labels:  cache, caching
Easycaching
πŸ’₯ EasyCaching is an open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easier!
Stars: ✭ 1,047 (+1225.32%)
Mutual labels:  cache, caching

logo minicache

Python memory caching utilities for Python 2 and 3 versions, also PyPy.

by Eugene Duboviy

Build Status Codacy Badge PyPI Code Health Open Source Love PRs & Issues Welcome Awesome

Why?

A major problem of funcy.memoize you couldn't test with it because there was no (obvious) way to turn it off. This project was created to suit the "memoization" needs, with a hook to turn it off (for testing or other purposes).

Current features

  • Simple set and get workflow
  • Decorator for "memoization" class methods and functions
  • Enabling and disabling functionality (including a context manager)
  • No additional packages required to be installed (using only standard python lib)

Installation

Install from PyPI:

pip install minicache

Or using alternative command:

pip install https://github.com/duboviy/minicache/archive/master.zip

Or from source use:

python setup.py install

Supported python versions

  • 2.7
  • 3.3
  • 3.4
  • 3.5
  • PyPy

PyPI

Examples

Basic usage

>>> from minicache import cache
>>> cache.has('key')
False
>>> cache.get('key', default='default')
'default'
>>> cache.update('key', 'value')
>>> cache.get('key')
'value'
>>> cache.disable()
>>> cache.get('key')

Decorator and context manager

from minicache import cache
import time

@cache.this
def somefunc():
    time.sleep(5)
    return "this will be cached, and you won't have to wait a second time!"

def test_somefunc():
    somefunc()
    somefunc()
    with cache.temporarily_disabled():
        # now we'll have to wait again
        somefunc()

Decorator for "memoization" class methods:

class Foo(Cacheable):
    def __init__(self):
        super(Foo, self).__init__()
        self._bar = 5

    @property
    @Cacheable.cached
    def m1(self):
        print('actual call property...', self._bar)
        return self._bar

    @Cacheable.cached
    def m2(self, a, b, k=4, m=10):
        s = a + b + k + m
        print('actual call method...', a, b, k, m, s)
        return s

    @Cacheable.cached
    def m3(self, a=3, b=2):
        s = a + b
        print('actual call method (kwargs only)', a, b, s)
        return s

... and many other features

License

MIT licensed library. See LICENSE for details.

Contributing

If you have suggestions for improving the minicache, please open an issue or pull request on GitHub.

Badges

forthebadge forthebadge forthebadge forthebadge

forthebadge forthebadge forthebadge forthebadge

Open Source Love

forthebadge

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].