An open API service indexing awesome lists of open source software.

https://github.com/redis-developer/basic-caching-demo-python

This project shows a basic caching demo in Python
https://github.com/redis-developer/basic-caching-demo-python

Last synced: 10 months ago
JSON representation

This project shows a basic caching demo in Python

Awesome Lists containing this project

README

          



# Django(python) Redis caching Example

Show how the redis works with Django(Python).

# Overview video

Here's a short video that explains the project and how it uses Redis:

[![Watch the video on YouTube](https://github.com/redis-developer/basic-caching-demo-python/raw/dev/docs/YTThumbnail.png)](https://youtube.com/watch?v=x4dwTM97tBM)

# Redis rate-caching example front

![How it works](https://github.com/redis-developer/basic-caching-demo-python/raw/dev/docs/screenshot001.png)

# Redis rate-caching example (command line)

![How it works](https://github.com/redis-developer/basic-caching-demo-python/raw/dev/docs/radis-ching.png)

## Try it out



Deploy to Heorku




Deploy with Vercel




Run on Google Cloud

(See notes: How to run on Google Cloud)

## How to run on Google Cloud


After successful deployment, you need to manually enable the vpc connector as shown in the pictures:

1. Open link google cloud console.
![1 step](https://github.com/redis-developer/basic-caching-demo-python/raw/dev/docs/1.png)
2. Click "Edit and deploy new revision" button.
![2 step](https://github.com/redis-developer/basic-caching-demo-python/raw/dev/docs/2.png)
3. Select vpc-connector and deploy application.
![3 step](https://github.com/redis-developer/basic-caching-demo-python/raw/dev/docs/3.png)


Problem with unsupported the flags when deploying google cloud run button

---

## How to run it locally?

### Run docker compose or install redis manually
Install docker (on mac: https://docs.docker.com/docker-for-mac/install/)

```sh
docker network create global
docker-compose up -d --build
```

#### If you install redis manually open django-backend/configuration folder and copy `.env.example` to create `.env`. And provide the values for environment variables
- REDIS_HOST: Redis server host
- REDIS_PORT: Redis server port
- REDIS_DB: Redis server db index
- REDIS_PASSWORD: Redis server password

#### Setup and run backend
Install python, pip and venv (on mac: https://installpython3.com/mac/)

Use python version: 3.8
``` sh
python3 -m venv venv
source ./venv/bin/activate
pip3 install -r requirements.txt
python3 manage.py collectstatic
gunicorn configuration.asgi:application -b 127.0.0.1:5000 -k uvicorn.workers.UvicornWorker
```