Ce contenu n'est pas disponible dans la langue sélectionnée.
8.3. Configure Image Cache
You can configure the Image service API to have a local image cache. Caching of image files is transparent and can be performed by modifying some configuration parameters.
These parameters are configured in the PasteDeploy configuration file, component-paste.ini. You should not generally edit this file directly, as it ships with default options for all common deployment flavors.
8.3.1. Enable the Image Cache Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
To enable the image cache parameters, the cache parameters must occur in the application pipeline after the appropriate context parameters.
The cache parameters should be in your
glance-api-paste.ini
in a section titled [filter:cache]
. It should look like this:
[filter:cache] paste.filter_factory = glance.api.middleware.cache:CacheFilter.factory
[filter:cache]
paste.filter_factory = glance.api.middleware.cache:CacheFilter.factory
A ready-made application parameter including this filter is defined in the
glance-api-paste.ini
file as follows:
[pipeline:glance-api-caching] pipeline = versionnegotiation context cache apiv1app
[pipeline:glance-api-caching]
pipeline = versionnegotiation context cache apiv1app
To enable the above application parameter, in your main
glance-api.conf
configuration file, select the appropriate deployment flavor as follows:
[paste_deploy] flavor = caching
[paste_deploy]
flavor = caching
8.3.2. Enable the Image Cache Management Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
There is an optional
cachemanage
option that allows you to directly interact with cache images. Use this flavor in place of the cache flavor in your API config file.
[paste_deploy] flavor = cachemanage
[paste_deploy]
flavor = cachemanage
8.3.3. Configuration Options Affecting the Image Cache Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
These configuration options must be set in both the
glance-cache
and glance-api
configuration files.
Configuration option = Default value | Description |
---|---|
image_cache_dir = /var/lib/glance/image-cache
|
Required when image cache middleware is enabled. This is the base directory the image cache can write files to. Make sure the directory is writable by the user running the glance-api server.
|
image_cache_driver = sqlite
|
(Optional) The default sqlite cache driver has no special dependencies, other than the python-sqlite3 library, which is installed on almost all operating systems with modern versions of Python. It stores information about the cached files in a SQLite database.
The
xattr cache driver requires the python-xattr>=0.6.0 library and requires that the filesystem containing image_cache_dir has access times tracked for all files (in other words, the noatime option CANNOT be set for that filesystem). In addition, user_xattr must be set on the filesystem’s description line in fstab.
|
image_cache_sqlite_db = cache.db
|
(Optional) When using the sqlite cache driver, you can set the name of the database that will be used to store the cached images information. The database is always contained in the image_cache_dir .
|
image_cache_max_size = 10737418240 (10 GB)
|
(Optional) Size, in bytes, that the image cache should be constrained to. Images files are cached automatically in the local image cache, even if the writing of that image file would put the total cache size over this size. The glance-cache-pruner executable is what prunes the image cache to be equal to or less than this value. The glance-cache-pruner executable is designed to be run via cron on a regular basis.
|