此内容没有您所选择的语言版本。

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

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
Copy to Clipboard Toggle word wrap
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
Copy to Clipboard Toggle word wrap
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
Copy to Clipboard Toggle word wrap

8.3.2. Enable the Image Cache Management

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
Copy to Clipboard Toggle word wrap

8.3.3. Configuration Options Affecting the Image Cache

These configuration options must be set in both the glance-cache and glance-api configuration files.
Expand
Table 8.23. Description of Image Cache configuration options
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.
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat