Skip to content

Commit

Permalink
[#20] Removed support for Tornado
Browse files Browse the repository at this point in the history
  • Loading branch information
zmumi committed May 6, 2024
1 parent f271ae5 commit 943971b
Show file tree
Hide file tree
Showing 30 changed files with 409 additions and 1,146 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
3.0.0
-----

* Removed support for Tornado

2.1.0
-----

Expand Down
72 changes: 3 additions & 69 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Extended docs (including API docs) available at `memoize.readthedocs.io <https:/
What & Why
==========

**What:** Caching library for asynchronous Python applications.
**What:** Caching library for asyncio Python applications.

**Why:** Python deserves library that works in async world
(for instance handles `dog-piling <https://en.wikipedia.org/wiki/Cache_stampede>`_ )
Expand Down Expand Up @@ -55,12 +55,6 @@ To get you up & running all you need is to install:
Installation of Extras
~~~~~~~~~~~~~~~~~~~~~~

If you are going to use ``memoize`` with tornado add a dependency on extra:

.. code-block:: bash
pip install py-memoize[tornado]
To harness the power of `ujson <https://pypi.org/project/ujson/>`_ (if JSON SerDe is used) install extra:

.. code-block:: bash
Expand All @@ -73,19 +67,13 @@ Usage
Provided examples use default configuration to cache results in memory.
For configuration options see `Configurability`_.

You can use ``memoize`` with both `asyncio <https://docs.python.org/3/library/asyncio.html>`_
and `Tornado <https://github.com/tornadoweb/tornado>`_ - please see the appropriate example:

.. warning::
Support for `Tornado <https://github.com/tornadoweb/tornado>`_ is planned to be removed in the future.

asyncio
~~~~~~~

To apply default caching configuration use:

..
_example_source: examples/basic/basic_asyncio.py
_example_source: examples/basic/basic.py
.. code-block:: python
Expand All @@ -109,45 +97,6 @@ To apply default caching configuration use:
asyncio.get_event_loop().run_until_complete(main())
Tornado
~~~~~~~

If your project is based on Tornado use:

..
_example_source: examples/basic/basic_tornado.py
.. code-block:: python
import random
from tornado import gen
from tornado.ioloop import IOLoop
from memoize.wrapper import memoize
@memoize()
@gen.coroutine
def expensive_computation():
return 'expensive-computation-' + str(random.randint(1, 100))
@gen.coroutine
def main():
result1 = yield expensive_computation()
print(result1)
result2 = yield expensive_computation()
print(result2)
result3 = yield expensive_computation()
print(result3)
if __name__ == "__main__":
IOLoop.current().run_sync(main)
Features
========

Expand All @@ -162,21 +111,6 @@ This library is built async-oriented from the ground-up, what manifests in, for
in `Dog-piling proofness`_ or `Async cache storage`_.


Tornado & asyncio support
-------------------------

No matter what are you using, build-in `asyncio <https://docs.python.org/3/library/asyncio.html>`_
or its predecessor `Tornado <https://github.com/tornadoweb/tornado>`_
*memoize* has you covered as you can use it with both.
**This may come handy if you are planning a migration from Tornado to asyncio.**

Under the hood *memoize* detects if you are using *Tornado* or *asyncio*
(by checking if *Tornado* is installed and available to import).

If have *Tornado* installed but your application uses *asyncio* IO-loop,
set ``MEMOIZE_FORCE_ASYNCIO=1`` environment variable to force using *asyncio* and ignore *Tornado* instalation.


Configurability
---------------

Expand Down Expand Up @@ -310,7 +244,7 @@ On failure, all requesters get an exception (same happens on timeout).
An example of what it all is about:

..
_example_source: examples/dogpiling/dogpiling_asyncio.py
_example_source: examples/dogpiling/dogpiling.py
.. code-block:: python
Expand Down
16 changes: 0 additions & 16 deletions docs/source/memoize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ memoize package
Submodules
----------

memoize.coerced module
----------------------

.. automodule:: memoize.coerced
:members:
:undoc-members:
:show-inheritance:

memoize.configuration module
----------------------------

Expand Down Expand Up @@ -68,14 +60,6 @@ memoize.key module
:undoc-members:
:show-inheritance:

memoize.memoize\_configuration module
-------------------------------------

.. automodule:: memoize.memoize_configuration
:members:
:undoc-members:
:show-inheritance:

memoize.postprocessing module
-----------------------------

Expand Down
6 changes: 1 addition & 5 deletions examples/basic/basic_asyncio.py → examples/basic/basic.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
from memoize import memoize_configuration

# needed if one has tornado installed (could be removed otherwise)
memoize_configuration.force_asyncio = True

import asyncio
import random

from memoize.wrapper import memoize


Expand Down
26 changes: 0 additions & 26 deletions examples/basic/basic_tornado.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from memoize import memoize_configuration

# needed if one has tornado installed (could be removed otherwise)
memoize_configuration.force_asyncio = True

import asyncio
from datetime import timedelta

Expand Down Expand Up @@ -54,5 +49,6 @@ async def main():
# Other cache generated 85 unique backend calls
# Predicted (according to TTL) 17 unique backend calls


if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
45 changes: 0 additions & 45 deletions examples/dogpiling/dogpiling_tornado.py

This file was deleted.

6 changes: 1 addition & 5 deletions examples/invalidation/invalidation.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# needed if one has tornado installed (could be removed otherwise)
from memoize import memoize_configuration
memoize_configuration.force_asyncio = True

from memoize.configuration import DefaultInMemoryCacheConfiguration
from memoize.invalidation import InvalidationSupport


import asyncio
import random
from memoize.wrapper import memoize
Expand Down Expand Up @@ -43,5 +38,6 @@ async def main():
# Invalidation # 2
# expensive - computation - 59


if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
8 changes: 2 additions & 6 deletions examples/ttl/ttl_asyncio.py → examples/ttl/ttl.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
# needed if one has tornado installed (could be removed otherwise)
from memoize import memoize_configuration
memoize_configuration.force_asyncio = True

import datetime
import asyncio
import datetime
import random
from dataclasses import dataclass

from memoize.wrapper import memoize
from memoize.configuration import DefaultInMemoryCacheConfiguration, MutableCacheConfiguration
from memoize.entry import CacheKey, CacheEntry
from memoize.entrybuilder import CacheEntryBuilder
from memoize.storage import LocalInMemoryCacheStorage
from memoize.wrapper import memoize


@dataclass
Expand Down
Loading

0 comments on commit 943971b

Please sign in to comment.