Flask caching

Description of caching in python in the Flask framework.

Installation

Flask has a caching module Flask-Caching… It supports different types of caches and requires additional configuration. Instead of Flask-Caching, we will immediately install the module to work with memcached… There are many different modules for working with it. The most popular is pylibmc written in C. I will continue to use the module pymemcache

Install the memcached module:

How to install memcached service on Mac OS and memcached on Ubuntu.

Integration

In the __init__.py file, add:

from pymemcache.client import base
cache = base.Client ((‘localhost’, 11211))

Using

from app import cache
cache.set (‘running’, ‘1’)
cache_running = cache.get (“running”)
cache.delete (“running”)

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *