https://github.com/fastack-dev/fastack-cache
https://github.com/fastack-dev/fastack-cache
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/fastack-dev/fastack-cache
- Owner: fastack-dev
- License: mit
- Created: 2021-12-20T11:16:26.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-04-29T16:48:55.000Z (about 2 years ago)
- Last Synced: 2024-04-29T18:03:06.491Z (about 2 years ago)
- Language: Python
- Size: 104 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fastack-cache
fastack-cache is a caching plugin for [fastack](https://github.com/fastack-dev/fastack) ❤️
This plugin is inspired by the [django cache framework](https://docs.djangoproject.com/en/4.0/topics/cache/) and [django-redis](https://github.com/jazzband/django-redis)!
Supported cache backend:
* Redis:
* ``fastack_cache.backends.redis.RedisBackend`` - Sync version
* ``fastack_cache.backends.aioredis.AioRedisBackend`` - Async version
# Installation
```
pip install -U fastack-cache
```
# Usage
Add the plugin to your project configuration:
```python
PLUGINS = [
"fastack_cache",
...
]
```
Configuration:
```python
REDIS_HOST = "localhost"
REDIS_PORT = 6900
REDIS_DB = 0
CACHES = {
# cache name
"default": {
# cache backend
"BACKEND": "fastack_cache.backends.redis.RedisBackend",
# Cache options to be passed to the Redis(...) class
"OPTIONS": {
"host": REDIS_HOST,
"port": REDIS_PORT,
"db": REDIS_DB,
},
# Serializer for converting data into cache
"SERIALIZER": {
"CLASS": "fastack_cache.serializers.JSONSerializer",
"OPTIONS": {
# Option to pass when dumps() method in serializer class is called
"DUMPS": {},
# Option to pass when loads() method in serializer class is called
"LOADS": {}
}
}
}
}
```