Skip to content

Commit

Permalink
Merge pull request #12 from yola/fix/md-to-rst
Browse files Browse the repository at this point in the history
Fix/md to rst
  • Loading branch information
zoidyzoidzoid committed May 19, 2014
2 parents 2cd0289 + af59ca1 commit 388349a
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 57 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 1.0.3
* Converted README from markdown to reStructuredText so it works on PyPi.

## 1.0.2
* Adds Python 3 support

Expand Down
56 changes: 0 additions & 56 deletions README.md

This file was deleted.

76 changes: 76 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
Property caching
================
.. image:: https://travis-ci.org/yola/property-caching.svg?branch=fix/md-to-rst
:target: https://travis-ci.org/yola/property-caching


Cached version of property

Written and used by the folks at Yola to support our `free website
builder`_.

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
-----

.. code:: python
from property_caching import (cached_property,
class_cached_property,
clear_property_cache,
set_property_cache)
class Dummy:
@cached_property
def foo(self):
return self.service.expensive_operation()
@class_cached_property
def service(self):
return expensive_service_initialization()
d = Dummy()
d.foo # calculates result and stores it in d._cached_properties
d.foo # 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()
d2.foo # re-calculates value of `foo` but uses cached service
Testing
-------

Install development requirements:

::

pip install -r requirements.txt

Run the tests with:

::

python setup.py test

.. _free website builder: https://www.yola.com/

.. image:: https://travis-ci.org/yola/property-caching.svg?branch=fix/md-to-rst
:target: https://travis-ci.org/yola/property-caching
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='property-caching',
version='1.0.2',
version='1.0.3',
description='Property caching',
author='Yola',
author_email='[email protected]',
Expand Down

0 comments on commit 388349a

Please sign in to comment.