Skip to content

Commit

Permalink
Add docs for the put() and get() result-store methods.
Browse files Browse the repository at this point in the history
Refs #394

[skip ci]
  • Loading branch information
coleifer committed Feb 16, 2019
1 parent 1c39de8 commit 4d2f1e0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
32 changes: 31 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,21 @@ Function decorators and helpers
the periodic task happens inside the consumer scheduler. As such,
there is no task result handle which the user could use to read the
result. To store the results of periodic tasks, you will need to
use your own storage.
use your own storage or use the storage APIs directly:

.. code-block:: python
@huey.periodic_task(crontab(minute='*/10'))
def my_task():
# do some work...
do_something()
# Manually store some data in the result store.
huey.put('my-task', some_data_to_store)
More info:

* :py:meth:`Huey.put`
* :py:meth:`Huey.get`

.. py:method:: enqueue(task)
Expand Down Expand Up @@ -501,6 +515,22 @@ Function decorators and helpers
:param str lock_name: Name to use for the lock.
:return: Decorator or context-manager.

.. py:method:: put(key, value)
:param key: key for data
:param value: arbitrary data to store in result store.

Store a value in the result-store under the given key.

.. py:method:: get(key[, peek=False])
:param key: key to read
:param bool peek: non-destructive read

Read a value from the result-store at the given key. By default reads
are destructive, but to preserve the value you can specify
``peek=True``.

.. py:method:: pending([limit=None])
Return all unexecuted tasks currently in the queue.
Expand Down
4 changes: 3 additions & 1 deletion docs/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ Now, when we run the consumer it will start printing the time every minute:
.. image:: crontab.png

.. note::
Periodic task return value will not be stored in the result store.
Periodic task return value will not be stored in the result store. You can
manually store data in the result store, however, by using the
:py:meth:`Huey.put` and :py:meth:`Huey.get` result store APIs.

Canceling or pausing tasks
--------------------------
Expand Down

0 comments on commit 4d2f1e0

Please sign in to comment.