Skip to main content

Latest Version Build Status

A Really! Small! Cache! for python 2 and 3.

Why?

Working on a totally separate project, I found myself wanting to use funcy.memoize…a lot. There was a major problem, though: I couldn’t test with it. There was no (obvious) way to turn it off. It was making me crazy, so I spent a few hours writing a small module (even smaller than this, originally) to suit the memoization needs, with a hook to turn it off for testing. When I got to the end of my feature sprint for that project, I decided it made more sense to spin it out into its own project, so here we are!

Current features

  • Simple upsert and get workflow

  • Decorator for “memoization”

  • Enabling and disabling functionality, including a context manager

  • Work directly on the imported module… no additional instantiation

Installation

pip install microcache

Examples

Basic usage

>>> import microcache
>>> microcache.has('key')
False
>>> microcache.get('key', default='default')
'default'
>>> microcache.upsert('key', 'value')
>>> microcache.get('key')
'value'
>>> microcache.disable()
>>> microcache.get('key')

Decorator and context manager

import microcache
import time

@microcache.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 microcache.temporarily_disabled():
        # now we'll have to wait again
        somefunc()

Metadata

Release files for microcache 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for microcache 0.2.1
File Size Uploaded
microcache-0.2.1.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for microcache 0.2.1
File Interpreter ABI Platform
microcache-0.2.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 7.2 kB

Release files / microcache-0.2.1.tar.gz

Download URL microcache-0.2.1.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2c050a1cec4409a809089d4ce6911ae3e31acdd360ab51ec235ddd21f4f163d6
BLAKE2b-256 checksum
How to use checksums
1fe2c20cdbb73cc5d8dec118b475cd4b17145e272bc321fad84726b4b6d7f3c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / microcache-0.2.1-py2.py3-none-any.whl

Download URL microcache-0.2.1-py2.py3-none-any.whl
Size 3.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
7f2b7cae43311d60d649b906234dc2d02cfbd30c14fcd8b0d6dda33bb49bfabd
BLAKE2b-256 checksum
How to use checksums
97e408cefd6d6c89c6f434e365d6c1754eb11ed06df8f31359e05f02eb52799e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

1.0

2 release files

0.4

2 release files

0.3

2 release files

This release

0.2.1 This release

2 release files

0.2

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page