Skip to content

Commit

Permalink
Updated notes on using a cache instance when initializing ``OAuth…
Browse files Browse the repository at this point in the history
…``. (#693)

* Updated notes on using a ``cache`` instance when initializing ``OAuth``.
  • Loading branch information
iSOLveIT authored Dec 18, 2024
1 parent fbdbbd6 commit 5a0ca3c
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions docs/client/flask.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,46 @@ system. When initializing ``OAuth``, you can pass an ``cache`` instance::

A ``cache`` instance MUST have methods:

- ``.delete(key)``
- ``.get(key)``
- ``.set(key, value, expires=None)``

An example of a ``cache`` instance can be:

.. code-block:: python
from flask import Flask
class OAuthCache:
def __init__(self, app: Flask) -> None:
"""Initialize the AuthCache."""
self.app = app
def delete(self, key: str) -> None:
"""
Delete a cache entry.
:param key: Unique identifier for the cache entry.
"""
def get(self, key: str) -> str | None:
"""
Retrieve a value from the cache.
:param key: Unique identifier for the cache entry.
:return: Retrieved value or None if not found or expired.
"""
def set(self, key: str, value: str, expires: int | None = None) -> None:
"""
Set a value in the cache with optional expiration.
:param key: Unique identifier for the cache entry.
:param value: Value to be stored.
:param expires: Expiration time in seconds. Defaults to None (no expiration).
"""
Routes for Authorization
------------------------
Expand Down

0 comments on commit 5a0ca3c

Please sign in to comment.