If your blueprint requires memcached support, RelengAPI can supply you with a python-memcached connection instance based on the user's configuration.
The configuration syntax is described in Memcached.
To get the Client instance, pass the configuration value to
app.memcached.cache, using the result as a context manager.
@bp.route('/bears') def get_bears(): with current_app.memcached.get(current_app.config['BEAR_CACHE']) as mc: mc.get(..) ..
This usage ensures that the (non-thread-safe!)
Client instance can be safely re-used as necessary by other threads.
This minimizes the number of new memcached connections required, while ensuring instances aren't used simultaneously by multiple threads.