Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow the configuration of any opcache variable #418

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ For custom opcache.so location provide full path with `php_opcache_zend_extensio

The platform-specific opcache configuration filename. Generally the default should work, but in some cases, you may need to override the filename.

Additionally, any variable matching the `^php_opcache_.*$` regex will be converted into the corresponding opcache ini variable. \
For instance, `php_opcache_jit_buffer_size: 256` will automatically be converted into `opcache.jit_buffer_size=256` in the opcache ini file.

### APCu-related Variables

php_enable_apc: true
Expand Down
13 changes: 3 additions & 10 deletions templates/opcache.ini.j2
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
zend_extension={{ php_opcache_zend_extension }}
opcache.enable={{ php_opcache_enable }}
opcache.enable_cli={{ php_opcache_enable_cli }}
opcache.memory_consumption={{ php_opcache_memory_consumption }}
opcache.interned_strings_buffer={{ php_opcache_interned_strings_buffer }}
opcache.max_accelerated_files={{ php_opcache_max_accelerated_files }}
opcache.max_wasted_percentage={{ php_opcache_max_wasted_percentage }}
opcache.validate_timestamps={{ php_opcache_validate_timestamps }}
opcache.revalidate_path={{ php_opcache_revalidate_path }}
opcache.revalidate_freq={{ php_opcache_revalidate_freq }}
opcache.max_file_size={{ php_opcache_max_file_size }}
{% for key, var in opcache_vars.items() %}
opcache.{{ key }}={{ var }}
{% endfor %}
{% if php_opcache_blacklist_filename != '' %}
opcache.blacklist_filename={{ php_opcache_blacklist_filename }}
{% endif %}
13 changes: 13 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
__opcache_var_names: "{{ lookup('varnames',
'^php_opcache_(?!(zend_extension|conf_filename|blacklist_filename)).*$',
wantlist=True) }}"
__opcache_var_values: "{{ lookup('vars',
*__opcache_var_names,
wantlist=True) }}"
opcache_vars: "{{ __opcache_var_names
| map('regex_replace', '^(php_opcache_)', '')
| map('community.general.dict_kv', 'key')
| zip(__opcache_var_values
| map('community.general.dict_kv', 'value'))
| map('combine')
| items2dict }}"