Skip to main content

Property caching

Project description

# Property caching

[![Build Status](](

Cached version of property

Written and used by the folks at Yola to support our [free website builder][1].

## Overview

- `cached_property` - stores results of decorated methods in decorated object
(in `_cached_properties` attribute)
- `class_cached_property` - stores results of decorated methods in the class of decorated object
(in `_class_cached_properties` attribute). All instances will share cached value.
- `clear_property_cache` - deletes cached value (works for object cached properties only)
- `set_property_cache` - explicitly sets property cache (works for object cached properties only)
- `is_property_cached` - allows to check whether property was cached or not (works for object cached properties only)

## Usage
from property_caching import (cached_property,

class Dummy:
def foo(self):
return self.service.expensive_operation()

def service(self):
return expensive_service_initialization()

d = Dummy() # calculates result and stores it in d._cached_properties # uses cached value

clear_property_cache(d, 'foo') # clears cache for property `foo`
set_property_cache(d, 'foo', 42) # explicitly set cache for property `foo`

d2 = Dummy() # re-calculates value of `foo` but uses cached service

## Testing

Install development requirements:

pip install -r requirements.txt

Run the tests with:



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 property-caching, version 1.0.2
Filename, size File type Python version Upload date Hashes
Filename, size property-caching-1.0.2.tar.gz (3.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page