Flask-Caching Documentation

43
Flask-Caching Documentation Release 1.0.0 Thadeus Burgess, Peter Justin Feb 24, 2019

Transcript of Flask-Caching Documentation

Flask-Caching DocumentationRelease 1.0.0

Thadeus Burgess, Peter Justin

Feb 24, 2019

Contents

1 Installation 3

2 Set Up 5

3 Caching View Functions 7

4 Caching Other Functions 9

5 Memoization 115.1 Deleting memoize cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

6 Caching Jinja2 Snippets 13

7 Clearing Cache 15

8 Configuring Flask-Caching 17

9 Built-in Cache Backends 219.1 NullCache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219.2 SimpleCache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219.3 FileSystemCache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219.4 RedisCache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229.5 RedisSentinelCache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229.6 MemcachedCache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229.7 SASLMemcachedCache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239.8 SpreadSASLMemcachedCache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

10 Custom Cache Backends 25

11 API 27

12 Additional Information 2912.1 Changelog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2912.2 License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

Python Module Index 37

i

ii

Flask-Caching Documentation, Release 1.0.0

Flask-Caching is an extension to Flask that adds caching support for various backends to any Flask application. Besidesproviding support for all werkzeug’s original caching backends through a uniformed API, it is also possible to developyour own caching backend by subclassing flask_caching.backends.base.BaseCache class.

Contents 1

Flask-Caching Documentation, Release 1.0.0

2 Contents

CHAPTER 1

Installation

Install the extension with one of the following commands:

$ easy_install Flask-Caching

or alternatively if you have pip installed:

$ pip install Flask-Caching

3

Flask-Caching Documentation, Release 1.0.0

4 Chapter 1. Installation

CHAPTER 2

Set Up

Cache is managed through a Cache instance:

from flask import Flaskfrom flask_caching import Cache

app = Flask(__name__)# Check Configuring Flask-Caching section for more detailscache = Cache(app, config={'CACHE_TYPE': 'simple'})

You may also set up your Cache instance later at configuration time using init_app method:

cache = Cache(config={'CACHE_TYPE': 'simple'})

app = Flask(__name__)cache.init_app(app)

You may also provide an alternate configuration dictionary, useful if there will be multiple Cache instances each witha different backend:

#: Method A: During instantiation of classcache = Cache(config={'CACHE_TYPE': 'simple'})#: Method B: During init_app callcache.init_app(app, config={'CACHE_TYPE': 'simple'})

New in version 0.7.

5

Flask-Caching Documentation, Release 1.0.0

6 Chapter 2. Set Up

CHAPTER 3

Caching View Functions

To cache view functions you will use the cached() decorator. This decorator will use request.path by default for thecache_key:

@app.route("/")@cache.cached(timeout=50)def index():

return render_template('index.html')

The cached decorator has another optional argument called unless. This argument accepts a callable that returnsTrue or False. If unless returns True then it will bypass the caching mechanism entirely.

Warning: When using cached on a view, take care to put it between Flask’s @route decorator and yourfunction definition. Example:

@app.route('/')@cache.cached(timeout=50)def index():

return 'Cached for 50s'

If you reverse both decorator, what will be cached is the result of @route decorator, and not the result of yourview function.

7

Flask-Caching Documentation, Release 1.0.0

8 Chapter 3. Caching View Functions

CHAPTER 4

Caching Other Functions

Using the same @cached decorator you are able to cache the result of other non-view related functions. The onlystipulation is that you replace the key_prefix, otherwise it will use the request.path cache_key. Keys control whatshould be fetched from the cache. If, for example, a key does not exist in the cache, a new key-value entry will becreated in the cache. Otherwise the the value (i.e. the cached result) of the key will be returned:

@cache.cached(timeout=50, key_prefix='all_comments')def get_all_comments():

comments = do_serious_dbio()return [x.author for x in comments]

cached_comments = get_all_comments()

9

Flask-Caching Documentation, Release 1.0.0

10 Chapter 4. Caching Other Functions

CHAPTER 5

Memoization

See memoize()

In memoization, the functions arguments are also included into the cache_key.

Note: With functions that do not receive arguments, cached() and memoize() are effectively the same.

Memoize is also designed for methods, since it will take into account the identity. of the ‘self’ or ‘cls’ argument aspart of the cache key.

The theory behind memoization is that if you have a function you need to call several times in one request, it wouldonly be calculated the first time that function is called with those arguments. For example, an sqlalchemy object thatdetermines if a user has a role. You might need to call this function many times during a single request. To keep fromhitting the database every time this information is needed you might do something like the following:

class Person(db.Model):@cache.memoize(50)def has_membership(self, role_id):

return Group.query.filter_by(user=self, role_id=role_id).count() >= 1

Warning: Using mutable objects (classes, etc) as part of the cache key can become tricky. It is suggested to notpass in an object instance into a memoized function. However, the memoize does perform a repr() on the passedin arguments so that if the object has a __repr__ function that returns a uniquely identifying string for that object,that will be used as part of the cache key.

For example, an sqlalchemy person object that returns the database id as part of the unique identifier:

class Person(db.Model):def __repr__(self):

return "%s(%s)" % (self.__class__.__name__, self.id)

11

Flask-Caching Documentation, Release 1.0.0

5.1 Deleting memoize cache

New in version 0.2.

You might need to delete the cache on a per-function bases. Using the above example, lets say you change the userspermissions and assign them to a role, but now you need to re-calculate if they have certain memberships or not. Youcan do this with the delete_memoized() function:

cache.delete_memoized(user_has_membership)

Note: If only the function name is given as parameter, all the memoized versions of it will be invalidated. However,you can delete specific cache by providing the same parameter values as when caching. In following example only theuser-role cache is deleted:

user_has_membership('demo', 'admin')user_has_membership('demo', 'user')

cache.delete_memoized(user_has_membership, 'demo', 'user')

12 Chapter 5. Memoization

CHAPTER 6

Caching Jinja2 Snippets

Usage:

{% cache [timeout [,[key1, [key2, ...]]]] %}...{% endcache %}

By default, the value of “path to template file” + “block start line” is used as the cache key. Also, the key name can beset manually. Keys are concatenated together into a single string, that can be used to avoid the same block evaluatingin different templates.

Set the timeout to None for no timeout, but with custom keys:

{% cache None "key" %}...{% endcache %}

Set timeout to del to delete cached value:

{% cache 'del' key1 %}...{% endcache %}

If keys are provided, you may easily generate the template fragment key and delete it from outside of the templatecontext:

from flask_caching import make_template_fragment_keykey = make_template_fragment_key("key1", vary_on=["key2", "key3"])cache.delete(key)

Considering we have render_form_field and render_submit macros:

{% cache 60*5 %}<div>

<form>

(continues on next page)

13

Flask-Caching Documentation, Release 1.0.0

(continued from previous page)

{% render_form_field(form.username) %}{% render_submit() %}</form>

</div>{% endcache %}

14 Chapter 6. Caching Jinja2 Snippets

CHAPTER 7

Clearing Cache

See clear().

Here’s an example script to empty your application’s cache:

from flask_caching import Cache

from yourapp import app, your_cache_config

cache = Cache()

def main():cache.init_app(app, config=your_cache_config)

with app.app_context():cache.clear()

if __name__ == '__main__':main()

Warning: Some backend implementations do not support completely clearing the cache. Also, if you’re not usinga key prefix, some implementations (e.g. Redis) will flush the whole database. Make sure you’re not storing anyother data in your caching database.

15

Flask-Caching Documentation, Release 1.0.0

16 Chapter 7. Clearing Cache

CHAPTER 8

Configuring Flask-Caching

The following configuration values exist for Flask-Caching:

17

Flask-Caching Documentation, Release 1.0.0

CACHE_TYPE Specifies which type of caching object to use. This is animport string that will be imported and instantiated. It is as-sumed that the import object is a function that will return acache object that adheres to the cache API.For flask_caching.backends.cache objects, you do not needto specify the entire import string, just one of the followingnames.Built-in cache types:

• null: NullCache (default)• simple: SimpleCache• filesystem: FileSystemCache• redis: RedisCache (redis required)• redissentinel: RedisSentinelCache (redis required)• uwsgi: UWSGICache (uwsgi required)• memcached: MemcachedCache (pylibmc or mem-

cache required)• saslmemcached: SASLMemcachedCache (pylibmc

required)• spreadsaslmemcached: SpreadSASLMemcached-

Cache (pylibmc required)

CACHE_NO_NULL_WARNING Silents the warning message when using cache type of ‘null’.CACHE_ARGS Optional list to unpack and pass during the cache class in-

stantiation.CACHE_OPTIONS Optional dictionary to pass during the cache class instantia-

tion.CACHE_DEFAULT_TIMEOUT The default timeout that is used if no timeout is specified.

Unit of time is seconds.CACHE_THRESHOLD The maximum number of items the cache will store before

it starts deleting some. Used only for SimpleCache andFileSystemCache

CACHE_KEY_PREFIX A prefix that is added before all keys. This makes it possibleto use the same memcached server for different apps. Usedonly for RedisCache and MemcachedCache

CACHE_UWSGI_NAME The name of the uwsgi caching instance to connect to, forexample: mycache@localhost:3031, defaults to an emptystring, which means uWSGI will cache in the local instance.If the cache is in the same instance as the werkzeug app, youonly have to provide the name of the cache.

CACHE_MEMCACHED_SERVERS A list or a tuple of server addresses. Used only for Mem-cachedCache

CACHE_MEMCACHED_USERNAME Username for SASL authentication with memcached. Usedonly for SASLMemcachedCache

CACHE_MEMCACHED_PASSWORD Password for SASL authentication with memcached. Usedonly for SASLMemcachedCache

CACHE_REDIS_HOST A Redis server host. Used only for RedisCache.CACHE_REDIS_PORT A Redis server port. Default is 6379. Used only for Redis-

Cache.CACHE_REDIS_PASSWORD A Redis password for server. Used only for RedisCache and

RedisSentinelCache.CACHE_REDIS_DB A Redis db (zero-based number index). Default is 0. Used

only for RedisCache and RedisSentinelCache.CACHE_REDIS_SENTINELS A list or a tuple of Redis sentinel addresses. Used only for

RedisSentinelCache.CACHE_REDIS_SENTINEL_MASTER The name of the master server in a sentinel configuration.

Used only for RedisSentinelCache.CACHE_DIR Directory to store cache. Used only for FileSystemCache.CACHE_REDIS_URL URL to connect to Redis server. Example redis://

user:password@localhost:6379/2. Supportsprotocols redis://, rediss:// (redis over TLS)and unix://. See more info about URL support[here](http://redis-py.readthedocs.io/en/latest/index.html#redis.ConnectionPool.from_url). Used only for RedisCache.

18 Chapter 8. Configuring Flask-Caching

Flask-Caching Documentation, Release 1.0.0

In addition the standard Flask TESTING configuration option is used. If this is True then Flask-Caching will useNullCache only.

19

Flask-Caching Documentation, Release 1.0.0

20 Chapter 8. Configuring Flask-Caching

CHAPTER 9

Built-in Cache Backends

9.1 NullCache

Set CACHE_TYPE to null to use this type.

Cache that doesn’t cache

• CACHE_DEFAULT_TIMEOUT

9.2 SimpleCache

Set CACHE_TYPE to simple to use this type.

Uses a local python dictionary for caching. This is not really thread safe.

Relevant configuration values

• CACHE_DEFAULT_TIMEOUT

• CACHE_THRESHOLD

9.3 FileSystemCache

Set CACHE_TYPE to filesystem to use this type.

Uses the filesystem to store cached values

• CACHE_DEFAULT_TIMEOUT

• CACHE_DIR

• CACHE_THRESHOLD

• CACHE_OPTIONS

21

Flask-Caching Documentation, Release 1.0.0

There is a single valid entry in CACHE_OPTIONS: mode, which should be a 3 digit linux-style permissions octalmode.

9.4 RedisCache

Set CACHE_TYPE to redis to use this type.

• CACHE_DEFAULT_TIMEOUT

• CACHE_KEY_PREFIX

• CACHE_OPTIONS

• CACHE_REDIS_HOST

• CACHE_REDIS_PORT

• CACHE_REDIS_PASSWORD

• CACHE_REDIS_DB

• CACHE_REDIS_URL

Entries in CACHE_OPTIONS are passed to the redis client as **kwargs

9.5 RedisSentinelCache

Set CACHE_TYPE to redissentinel to use this type.

• CACHE_KEY_PREFIX

• CACHE_REDIS_SENTINELS

• CACHE_REDIS_SENTINEL_MASTER

• CACHE_REDIS_PASSWORD

• CACHE_REDIS_DB

Entries in CACHE_OPTIONS are passed to the redis client as **kwargs

9.6 MemcachedCache

Set CACHE_TYPE to memcached to use this type.

Uses a memcached server as a backend. Supports either pylibmc or memcache or google app engine memcache library.

Relevant configuration values

• CACHE_DEFAULT_TIMEOUT

• CACHE_KEY_PREFIX

• CACHE_MEMCACHED_SERVERS

Note: Flask-Caching does not pass additional configuration options to memcached backends. To add additionalconfiguration to these caches, directly set the configuration options on the object after instantiation:

22 Chapter 9. Built-in Cache Backends

Flask-Caching Documentation, Release 1.0.0

from flask_caching import Cachecache = Cache()

# Can't configure the client yet...cache.init_app(flask_app, {"CACHE_TYPE": "memcached"})

# Break convention and set options on the _client object# directly. For pylibmc behaviors:cache.cache._client.behaviors({"tcp_nodelay": True})

Alternatively, see Custom Cache Backends.

9.7 SASLMemcachedCache

Set CACHE_TYPE to saslmemcached to use this type.

Uses a memcached server as a backend. Intended to be used with a SASL enabled connection to the memcachedserver. pylibmc is required and SASL must be supported by libmemcached.

Relevant configuration values

• CACHE_DEFAULT_TIMEOUT

• CACHE_KEY_PREFIX

• CACHE_OPTIONS

• CACHE_MEMCACHED_SERVERS

• CACHE_MEMCACHED_USERNAME

• CACHE_MEMCACHED_PASSWORD

Note: Since the SASL Memcached cache types do not use werkzeug’s original built-in cache infrastructure, they canbe configured with CACHE_OPTIONS.

New in version 0.10.

9.8 SpreadSASLMemcachedCache

Set CACHE_TYPE to spreadsaslmemcached to use this type.

Same as SASLMemcachedCache however, it has the ablity to spread value across multiple keys if it is bigger than thememcached treshold which by default is 1M. Uses pickle.

New in version 0.11.

Changed in version 1.1.0: Renamed spreadsaslmemcachedcache to spreadsaslmemcached for the sakeof consistency.

9.7. SASLMemcachedCache 23

Flask-Caching Documentation, Release 1.0.0

24 Chapter 9. Built-in Cache Backends

CHAPTER 10

Custom Cache Backends

You are able to easily add your own custom cache backends by exposing a function that can instantiate and returna cache object. CACHE_TYPE will be the import string to your custom function. It should expect to receive threearguments.

• app

• args

• kwargs

Your custom cache object must also subclass the flask_caching.backends.cache.BaseCache class.Flask-Caching will make sure that threshold is already included in the kwargs options dictionary since it is com-mon to all BaseCache classes.

An example Redis cache implementation:

#: the_app/custom.pyclass RedisCache(BaseCache):

def __init__(self, servers, default_timeout=500):pass

def redis(app, config, args, kwargs):args.append(app.config['REDIS_SERVERS'])return RedisCache(*args, **kwargs)

With this example, your CACHE_TYPE might be the_app.custom.redis

An example PylibMC cache implementation to change binary setting and provide username/password if SASL isenabled on the library:

#: the_app/custom.pydef pylibmccache(app, config, args, kwargs):

return pylibmc.Client(servers=config['CACHE_MEMCACHED_SERVERS'],username=config['CACHE_MEMCACHED_USERNAME'],password=config['CACHE_MEMCACHED_PASSWORD'],binary=True)

25

Flask-Caching Documentation, Release 1.0.0

With this example, your CACHE_TYPE might be the_app.custom.pylibmccache

26 Chapter 10. Custom Cache Backends

CHAPTER 11

API

27

Flask-Caching Documentation, Release 1.0.0

28 Chapter 11. API

CHAPTER 12

Additional Information

12.1 Changelog

12.1.1 Version 1.5.0 2019-02-23

• Add support for a Redis Sentinel Cluster. PR #90.

• Parameterize the hash function so alternatives can be used. PR #77.

• Include the deprecated werkzeug.contrib.cache module in Flask-Caching. PR #75.

12.1.2 Version 1.4.0 2018-04-16

• Fix logic for creating key for var args in memoize. PR #70.

• Allow older Werkzeug versions by making the UWSGICache backend conditional. PR #55.

• Some documentation improvements. PR #48, #51, #56, #67.

• Some CI improvements. PR #49, #50.

12.1.3 Version 1.3.3 2017-06-25

• Add support for multiple query params and use md5 for consistent hashing. PR #43.

12.1.4 Version 1.3.2 2017-06-25

• Fix spreadsaslmemcached backend when using Python 3.

• Fix kwargs order when memoizing a function using Python 3.6 or greater. See #27.

29

Flask-Caching Documentation, Release 1.0.0

12.1.5 Version 1.3.1 2017-06-20

• Avoid breakage for environments with Werkzeug<0.12 installed because the uwsgi backend depends onWerkzeug >=0.12. See #38.

12.1.6 Version 1.3.0 2017-06-17

• Add uWSGI Caching backend (requires Werkzeug >= 0.12)

• Provide a keyword query_string to the cached decorator in order to create the same cache key for different querystring requests, so long as they have the same key/value (order does not matter). PR #35.

• Use pytest as test suite and test runner. Additionally, the tests have been split up into multiple files instead ofhaving one big file.

12.1.7 Version 1.2.0 2017-02-02

• Allows functions with kwargs to be memoized correctly. See #18.

12.1.8 Version 1.1.1 2016-12-09

• Fix PyPI Package distribution. See #15.

12.1.9 Version 1.1.0 2016-12-09

• Fix ‘redis’ backend import mechanisim. See #14.

• Made backends a module to better control which cache backends to expose and moved our custom clients intoa own module inside of the backends module. See also #14 (and partly some own changes).

• Some docs and test changes. See #8 and #12.

12.1.10 Version 1.0.1 2016-08-30

• The caching wrappers like add, set, etc are now returning the wrapped result as someone would expect. See #5.

12.1.11 Version 1.0.0 2016-07-05

• Changed the way of importing Flask-Cache. Instead of using the depreacted method for importing Flask Exten-sions (via flask.ext.cache), the name of the extension, flask_cache is used. Have a look at Flask’sdocumentation for more information regarding this matter. This also fixes the deprecation warning from Flask.

• Lots of PEP8 and Documentation fixes.

• Renamed this fork Flask-Caching (flask_caching) as it will now be available on PyPI for download.

In addition to the above mentioned fixes, following pull requests have been merged into this fork of Flask-Cache:

• #90 Update documentation: route decorator before cache

• #95 Pass the memoize parameters into unless().

• #109 wrapped function called twice

30 Chapter 12. Additional Information

Flask-Caching Documentation, Release 1.0.0

• #117 Moves setting the app attribute to the _set_cache method

• #121 fix doc for delete_memoized

• #122 Added proxy for werkzeug get_dict

• #123 “forced_update” option to ‘cache’ and ‘memoize’ decorators

• #124 Fix handling utf8 key args (cherry-picked)

• #125 Fix unittest failing for redis unittest

• #127 Improve doc for using @cached on view

• #128 Doc for delete_memoized

• #129 tries replacing inspect.getargspec with either signature or getfullargspec if possible

• make_cache_key() returning incorrect key (cherry-picked)

12.1.12 Version 0.13 2014-04-21

• Port to Python >= 3.3 (requiring Python 2.6/2.7 for 2.x).

• Fixed bug with using per-memoize timeouts greater than the default timeout

• Added better support for per-instance memoization.

• Various bug fixes

12.1.13 Version 0.12 2013-04-29

• Changes jinja2 cache templates to use stable predictable keys. Previously the key for a cache tag included theline number of the template, which made it difficult to predict what the key would be outside of the application.

• Adds config variable CACHE_NO_NULL_WARNING to silence warning messages when using ‘null’ cache aspart of testing.

• Adds passthrough to clear entire cache backend.

12.1.14 Version 0.11.1 2013-04-7

• Bugfix for using memoize on instance methods. The previous key was id(self), the new key is repr(self)

12.1.15 Version 0.11 2013-03-23

• Fail gracefully in production if cache backend raises an exception.

• Support for redis DB number

• Jinja2 templatetag cache now concats all args together into a single key instead of treating each arg as a separatekey name.

• Added delete memcache version hash function

• Support for multiple cache objects on a single app again.

• Added SpreadSASLMemcached, if a value is greater than the memcached threshold which defaults to 1MB,this splits the value across multiple keys.

12.1. Changelog 31

Flask-Caching Documentation, Release 1.0.0

• Added support to use URL to connect to redis.

12.1.16 Version 0.10.1 2013-01-13

• Added warning message when using cache type of ‘null’

• Changed imports to relative instead of absolute for AppEngine compatibility

12.1.17 Version 0.10.0 2013-01-05

• Added saslmemcached backend to support Memcached behind SASL authentication.

• Fixes a bug with memoize when the number of args != number of kwargs

12.1.18 Version 0.9.2 2012-11-18

• Bugfix with default kwargs

12.1.19 Version 0.9.1 2012-11-16

• Fixes broken memoized on functions that use default kwargs

12.1.20 Version 0.9.0 2012-10-14

• Fixes memoization to work on methods.

12.1.21 Version 0.8.0 2012-09-30

• Migrated to the new flask extension naming convention of flask_cache instead of flaskext.cache

• Removed unnecessary dependencies in setup.py file.

• Documentation updates

12.1.22 Version 0.7.0 2012-08-25

• Allows multiple cache objects to be instantiated with different configuration values.

12.1.23 Version 0.6.0 2012-08-12

• Memoization is now safer for multiple applications using the same backing store.

• Removed the explicit set of NullCache if the Flask app is set testing=True

• Swapped Conditional order for key_prefix

32 Chapter 12. Additional Information

Flask-Caching Documentation, Release 1.0.0

12.1.24 Version 0.5.0 2012-02-03

• Deleting memoized functions now properly functions in production environments where multiple instances ofthe application are running.

• get_memoized_names and get_memoized_keys have been removed.

• Added make_name to memoize, make_name is an optional callable that can be passed to memoize to modifythe cache_key that gets generated.

• Added unless to memoize, this is the same as the unless parameter in cached

• memoization now converts all kwargs to positional arguments, this is so that when a function is called multipleways, it would evaluate to the same cache_key

12.1.25 Version 0.4.0 2011-12-11

• Added attributes for uncached, make_cache_key, cache_timeout to the decorated functions.

12.1.26 Version 0.3.4 2011-09-10

• UTF-8 encoding of cache key

• key_prefix argument of the cached decorator now supports callables.

12.1.27 Version 0.3.3 2011-06-03

Uses base64 for memoize caching. This fixes rare issues where the cache_key was either a tuple or larger than thecaching backend would be able to support.

Adds support for deleting memoized caches optionally based on function parameters.

Python 2.5 compatibility, plus bugfix with string.format.

Added the ability to retrieve memoized function names or cache keys.

12.1.28 Version 0.3.2

Bugfix release. Fixes a bug that would cause an exception if no CACHE_TYPE was supplied.

12.1.29 Version 0.3.1

Pypi egg fix.

12.1.30 Version 0.3

• CACHE_TYPE changed. Now one of [‘null’, ‘simple’, ‘memcached’, ‘gaememcached’, ‘filesystem’], or animport string to a function that will instantiate a cache object. This allows Flask-Cache to be much moreextensible and configurable.

12.1. Changelog 33

Flask-Caching Documentation, Release 1.0.0

12.1.31 Version 0.2

• CACHE_TYPE now uses an import_string.

• Added CACHE_OPTIONS and CACHE_ARGS configuration values.

• Added delete_memoized

12.1.32 Version 0.1

• Initial public release

12.2 License

Copyright (c) 2010 by Thadeus Burgess.Copyright (c) 2016 by Peter Justin.

Some rights reserved.

Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions aremet:

* Redistributions of source code must retain the above copyrightnotice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the abovecopyright notice, this list of conditions and the followingdisclaimer in the documentation and/or other materials providedwith the distribution.

* The names of the contributors may not be used to endorse orpromote products derived from this software without specificprior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOTLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FORA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHTOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOTLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANYTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USEOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The "cache" module from werkzeug is licensed under a BSD-3 Clause license as isstated below:

Copyright (c) 2017, Pallets Team

All rights reserved.

(continues on next page)

34 Chapter 12. Additional Information

Flask-Caching Documentation, Release 1.0.0

(continued from previous page)

Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions aremet:

* Redistributions of source code must retain the above copyright notice,this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyrightnotice, this list of conditions and the following disclaimer in thedocumentation and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of itscontributors may be used to endorse or promote products derived fromthis software without specific prior written permission.

THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS ANDCONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY ANDFITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THECOPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUTNOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OFUSE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ONANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OFTHIS SOFTWARE AND DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OFSUCH DAMAGE.

• search

12.2. License 35

Flask-Caching Documentation, Release 1.0.0

36 Chapter 12. Additional Information

Python Module Index

fflask_caching, ??

37

Flask-Caching Documentation, Release 1.0.0

38 Python Module Index

Index

Fflask_caching (module), 1

39