| 1 |
from typing import Any |
| 2 |
|
| 3 |
from django_pgschemas.schema import get_current_schema |
| 4 |
|
| 5 |
|
| 6 |
def make_key(key: str, key_prefix: str, version: Any) -> str: |
| 7 |
""" |
| 8 |
Tenant aware function to generate a cache key. |
| 9 |
""" |
| 10 |
current_schema = get_current_schema() |
| 11 |
return "%s:%s:%s:%s" % (current_schema.schema_name, key_prefix, version, key) |
| 12 |
|
| 13 |
|
| 14 |
def reverse_key(key: str) -> str: |
| 15 |
""" |
| 16 |
Tenant aware function to reverse a cache key. |
| 17 |
|
| 18 |
Required for django-redis REVERSE_KEY_FUNCTION setting. |
| 19 |
""" |
| 20 |
return key.split(":", 3)[3] |