Added Flex cache configuration options

This commit is contained in:
Matias Griese
2020-01-21 10:02:29 +02:00
parent b850443090
commit 664447a67b
6 changed files with 113 additions and 32 deletions

View File

@@ -3,9 +3,12 @@
1. [](#new)
* _POTENTIAL BREAKING CHANGE:_ Upgraded Parsedown to 1.7 for Parsedown-Extra 0.8. Plugins that extend Parsedown may need a fix to render as HTML
* Added `$grav['flex']` to access all registered Flex Directories
* Added `FlexRegisterEvent` which triggers when `$grav['flex']` is being accessed the first time
* Added Flex cache configuration options
* Added `PluginsLoadedEvent` which triggers after plugins have been loaded but not yet initialized
* Added `SessionStartEvent` which triggers when session is started
* Added `RegisterPermissionsEvent` which triggers when `$grav['permissions']` is being accessed the first time
* Added `PermissionsRegisterEvent` which triggers when `$grav['permissions']` is being accessed the first time
1. [](#improved)
* Blueprint validation: Added `validate: value_type: bool|int|float|string|trim` to `array` to filter all the values inside the array
1. [](#bugfix)

View File

@@ -1472,22 +1472,30 @@ form:
title: PLUGIN_ADMIN.EXPERIMENTAL
underline: true
flex_pages:
type: section
title: Flex Pages
pages.type:
type: select
label: PLUGIN_ADMIN.PAGES_TYPE
highlight: stable
help: PLUGIN_ADMIN.PAGES_TYPE_HELP
options:
page: PLUGIN_ADMIN.REGULAR
regular: PLUGIN_ADMIN.REGULAR
flex: PLUGIN_ADMIN.FLEX
flex_accounts:
type: section
title: Flex Accounts
accounts.type:
type: select
label: PLUGIN_ADMIN.ACCOUNTS_TYPE
highlight: stable
help: PLUGIN_ADMIN.ACCOUNTS_TYPE_HELP
options:
data: PLUGIN_ADMIN.REGULAR
regular: PLUGIN_ADMIN.REGULAR
flex: PLUGIN_ADMIN.FLEX
accounts.storage:
@@ -1498,3 +1506,61 @@ form:
options:
file: PLUGIN_ADMIN.FILE
folder: PLUGIN_ADMIN.FOLDER
flex_caching:
type: section
title: PLUGIN_ADMIN.FLEX_CACHING
flex.cache.index.enabled:
type: toggle
label: PLUGIN_ADMIN.FLEX_INDEX_CACHE_ENABLED
highlight: 1
default: 1
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
flex.cache.index.lifetime:
type: text
label: PLUGIN_ADMIN.FLEX_INDEX_CACHE_LIFETIME
default: 60
validate:
type: int
flex.cache.object.enabled:
type: toggle
label: PLUGIN_ADMIN.FLEX_OBJECT_CACHE_ENABLED
highlight: 1
default: 1
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
flex.cache.object.lifetime:
type: text
label: PLUGIN_ADMIN.FLEX_OBJECT_CACHE_LIFETIME
default: 600
validate:
type: int
flex.cache.render.enabled:
type: toggle
label: PLUGIN_ADMIN.FLEX_RENDER_CACHE_ENABLED
highlight: 1
default: 1
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
flex.cache.render.lifetime:
type: text
label: PLUGIN_ADMIN.FLEX_RENDER_CACHE_LIFETIME
default: 600
validate:
type: int

View File

@@ -5,66 +5,66 @@ form:
plugin_tabs:
type: tabs
fields:
cache_tab:
cache:
type: tab
title: Caching
fields:
object.cache.index.enabled:
type: toggle
toggleable: true
label: Enable Index Caching
label: PLUGIN_ADMIN.FLEX_INDEX_CACHE_ENABLED
highlight: 1
config-default@: plugins.flex-objects.object.cache.index.enabled
config-default@: system.flex.cache.index.enabled
options:
1: Enabled
0: Disabled
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
object.cache.index.timeout:
object.cache.index.lifetime:
type: text
toggleable: true
label: Index Cache Timeout (s)
config-default@: plugins.flex-objects.object.cache.index.timeout
label: PLUGIN_ADMIN.FLEX_INDEX_CACHE_LIFETIME
config-default@: system.flex.cache.index.lifetime
validate:
type: int
object.cache.object.enabled:
type: toggle
toggleable: true
label: Enable Object Caching
label: PLUGIN_ADMIN.FLEX_OBJECT_CACHE_ENABLED
highlight: 1
config-default@: plugins.flex-objects.object.cache.object.enabled
config-default@: system.flex.cache.object.enabled
options:
1: Enabled
0: Disabled
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
object.cache.object.timeout:
object.cache.object.lifetime:
type: text
toggleable: true
label: Object Cache Timeout (s)
config-default@: plugins.flex-objects.object.cache.object.timeout
label: PLUGIN_ADMIN.FLEX_OBJECT_CACHE_LIFETIME
config-default@: system.flex.cache.object.lifetime
validate:
type: int
object.cache.render.enabled:
type: toggle
toggleable: true
label: Enable Render Caching
label: PLUGIN_ADMIN.FLEX_RENDER_CACHE_ENABLED
highlight: 1
config-default@: plugins.flex-objects.object.cache.render.enabled
config-default@: system.flex.cache.render.enabled
options:
1: Enabled
0: Disabled
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
object.cache.render.timeout:
object.cache.render.lifetime:
type: text
toggleable: true
label: Render Cache Timeout (s)
config-default@: plugins.flex-objects.object.cache.render.timeout
label: PLUGIN_ADMIN.FLEX_RENDER_CACHE_LIFETIME
config-default@: system.flex.cache.render.lifetime
validate:
type: int

View File

@@ -28,7 +28,7 @@ home:
hide_in_urls: false # Hide the home route in URLs
pages:
type: page # EXPERIMENTAL: Page type: page or flex
type: regular # EXPERIMENTAL: Page type: regular or flex
theme: quark # Default theme (defaults to "quark" theme)
order:
by: default # Order pages by "default", "alpha" or "date"
@@ -165,9 +165,21 @@ gpm:
official_gpm_only: true # By default GPM direct-install will only allow URLs via the official GPM proxy to ensure security
accounts:
type: data # EXPERIMENTAL: Account type: data or flex
type: regular # EXPERIMENTAL: Account type: regular or flex
storage: file # EXPERIMENTAL: Flex storage type: file or folder
flex:
cache:
index:
enabled: true # Set to true to enable Flex index caching. Is used to cache timestamps in files
lifetime: 60 # Lifetime of cached index in seconds (0 = infinite)
object:
enabled: true # Set to true to enable Flex object caching. Is used to cache object data
lifetime: 600 # Lifetime of cached objects in seconds (0 = infinite)
render:
enabled: true # Set to true to enable Flex render caching. Is used to cache rendered output
lifetime: 600 # Lifetime of cached HTML in seconds (0 = infinite)
strict_mode:
yaml_compat: true # Grav 1.5+: Enables YAML backwards compatibility
twig_compat: true # Grav 1.5+: Enables deprecated Twig autoescape setting (autoescape: false)

View File

@@ -1991,7 +1991,7 @@ class Pages
*/
protected function getVersion()
{
return $this->directory ? 'flex' : 'page';
return $this->directory ? 'flex' : 'regular';
}
/**

View File

@@ -52,7 +52,7 @@ class AccountsServiceProvider implements ServiceProviderInterface
$container['accounts'] = function (Container $container) {
$type = $this->initialize($container);
return $type === 'flex' ? $this->flexAccounts($container) : $this->dataAccounts($container);
return $type === 'flex' ? $this->flexAccounts($container) : $this->regularAccounts($container);
};
$container['user_groups'] = static function () {
@@ -69,7 +69,7 @@ class AccountsServiceProvider implements ServiceProviderInterface
protected function initialize(Container $container): string
{
$isDefined = defined('GRAV_USER_INSTANCE');
$type = strtolower($isDefined ? GRAV_USER_INSTANCE : $container['config']->get('system.accounts.type', 'data'));
$type = strtolower($isDefined ? GRAV_USER_INSTANCE : $container['config']->get('system.accounts.type', 'regular'));
if ($type === 'flex') {
if (!$isDefined) {
@@ -110,13 +110,13 @@ class AccountsServiceProvider implements ServiceProviderInterface
100000
);
} elseif (!$isDefined) {
define('GRAV_USER_INSTANCE', 'DATA');
define('GRAV_USER_INSTANCE', 'REGULAR');
}
return $type;
}
protected function dataAccounts(Container $container)
protected function regularAccounts(Container $container)
{
// Use User class for backwards compatibility.
return new DataUser\UserCollection(User::class);