mirror of
https://github.com/flextype/flextype.git
synced 2025-08-06 13:16:45 +02:00
feat(core): add ability to set custom cache id string and settings cache id string
This commit is contained in:
@@ -930,21 +930,21 @@ class Entries
|
||||
/**
|
||||
* Get Cache ID for entry.
|
||||
*
|
||||
* @param string $id Unique identifier of the Cache Entry Item.
|
||||
* @param string $salt Salt to append to the Cache ID.
|
||||
* @param string $id Unique identifier of the Cache Entry Item.
|
||||
* @param string $string String to append to the Cache ID.
|
||||
*
|
||||
* @return string Cache ID.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getCacheID(string $id, string $salt = ''): string
|
||||
public function getCacheID(string $id, string $string = ''): string
|
||||
{
|
||||
// Setup registry.
|
||||
$this->registry()->set('methods.getCacheID', [
|
||||
'collection' => $this->getCollectionOptions($id),
|
||||
'params' => [
|
||||
'id' => $id,
|
||||
'salt' => $salt,
|
||||
'string' => $string . registry()->get('flextype.settings.entries.cache.string'),
|
||||
],
|
||||
'result' => null,
|
||||
]);
|
||||
@@ -964,10 +964,10 @@ class Entries
|
||||
$entryFile = $this->getFileLocation($this->registry()->get('methods.getCacheID.params.id'));
|
||||
|
||||
if (filesystem()->file($entryFile)->exists()) {
|
||||
return strings($this->options['directory'] . $entryFile . $salt . (filesystem()->file($entryFile)->lastModified() ?: ''))->hash()->toString();
|
||||
return strings($this->options['directory'] . $entryFile . $string . (filesystem()->file($entryFile)->lastModified() ?: ''))->hash()->toString();
|
||||
}
|
||||
|
||||
return strings($this->options['directory'] . $entryFile . $salt)->hash()->toString();
|
||||
return strings($this->options['directory'] . $entryFile . $string)->hash()->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -109,7 +109,7 @@ final class Markdown
|
||||
*/
|
||||
public function parse(string $input)
|
||||
{
|
||||
$cache = registry()->get('flextype.settings.parsers.markdown.cache');
|
||||
$cache = registry()->get('flextype.settings.parsers.markdown.cache.enabled');
|
||||
|
||||
if ($cache === true && registry()->get('flextype.settings.cache.enabled') === true) {
|
||||
$key = $this->getCacheID($input);
|
||||
@@ -131,13 +131,14 @@ final class Markdown
|
||||
* Get Cache ID for markdown.
|
||||
*
|
||||
* @param string $input Input.
|
||||
* @param string $string String to append to the Cache ID.
|
||||
*
|
||||
* @return string Cache ID.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getCacheID(string $input): string
|
||||
public function getCacheID(string $input, string $string = ''): string
|
||||
{
|
||||
return strings('markdown' . $input)->hash()->toString();
|
||||
return strings('markdown' . $input . $string . registry()->get('flextype.settings.parsers.markdown.cache.string'))->hash()->toString();
|
||||
}
|
||||
}
|
||||
|
@@ -172,7 +172,7 @@ final class Shortcodes
|
||||
*/
|
||||
public function parse(string $input)
|
||||
{
|
||||
$cache = registry()->get('flextype.settings.parsers.shortcodes.cache');
|
||||
$cache = registry()->get('flextype.settings.parsers.shortcodes.cache.enabled');
|
||||
|
||||
if ($cache === true && registry()->get('flextype.settings.cache.enabled') === true) {
|
||||
$key = $this->getCacheID($input);
|
||||
@@ -194,13 +194,14 @@ final class Shortcodes
|
||||
* Get Cache ID for shortcode.
|
||||
*
|
||||
* @param string $input Input.
|
||||
*
|
||||
* @param string $string String to append to the Cache ID.
|
||||
*
|
||||
* @return string Cache ID.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getCacheID(string $input): string
|
||||
public function getCacheID(string $input, string $string = ''): string
|
||||
{
|
||||
return strings('shortcode' . $input)->hash()->toString();
|
||||
return strings('shortcode' . $input . $string . registry()->get('flextype.settings.parsers.shortcodes.cache.string'))->hash()->toString();
|
||||
}
|
||||
}
|
||||
|
@@ -103,7 +103,7 @@ final class Textile
|
||||
*/
|
||||
public function parse(string $input)
|
||||
{
|
||||
$cache = registry()->get('flextype.settings.parsers.textile.cache');
|
||||
$cache = registry()->get('flextype.settings.parsers.textile.cache.enabled');
|
||||
|
||||
if ($cache === true && registry()->get('flextype.settings.cache.enabled') === true) {
|
||||
$key = $this->getCacheID($input);
|
||||
@@ -124,14 +124,15 @@ final class Textile
|
||||
/**
|
||||
* Get Cache ID for textile.
|
||||
*
|
||||
* @param string $input Input.
|
||||
* @param string $input Input.
|
||||
* @param string $string String to append to the Cache ID.
|
||||
*
|
||||
* @return string Cache ID.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getCacheID(string $input): string
|
||||
public function getCacheID(string $input, string $string = ''): string
|
||||
{
|
||||
return strings('textile' . $input)->hash()->toString();
|
||||
return strings('textile' . $input . $string . registry()->get('flextype.settings.parsers.textile.cache.string'))->hash()->toString();
|
||||
}
|
||||
}
|
||||
|
@@ -74,8 +74,8 @@ class Frontmatter
|
||||
*/
|
||||
public function decode(string $input)
|
||||
{
|
||||
$cache = registry()->get('flextype.settings.serializers.frontmatter.decode.cache.enabled');
|
||||
$headerSerializer = registry()->get('flextype.settings.serializers.frontmatter.decode.header.serializer');
|
||||
$cache = registry()->get('flextype.settings.serializers.frontmatter.decode.cache');
|
||||
$allowed = registry()->get('flextype.settings.serializers.frontmatter.encode.header.allowed');
|
||||
|
||||
if ($headerSerializer === 'frontmatter') {
|
||||
@@ -138,14 +138,15 @@ class Frontmatter
|
||||
/**
|
||||
* Get Cache ID for frontmatter.
|
||||
*
|
||||
* @param string $input Input.
|
||||
* @param string $input Input.
|
||||
* @param string $string String to append to the Cache ID.
|
||||
*
|
||||
* @return string Cache ID.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getCacheID(string $input): string
|
||||
public function getCacheID(string $input, string $string = ''): string
|
||||
{
|
||||
return strings('frontmatter' . $input)->hash()->toString();
|
||||
return strings('frontmatter' . $input . $string . registry()->get('flextype.settings.serializers.frontmatter.decode.cache.string'))->hash()->toString();
|
||||
}
|
||||
}
|
||||
|
@@ -75,7 +75,7 @@ class Json
|
||||
*/
|
||||
public function decode(string $input)
|
||||
{
|
||||
$cache = registry()->get('flextype.settings.serializers.json.decode.cache');
|
||||
$cache = registry()->get('flextype.settings.serializers.json.decode.cache.enabled');
|
||||
$assoc = registry()->get('flextype.settings.serializers.json.decode.assoc');
|
||||
$depth = registry()->get('flextype.settings.serializers.json.decode.depth');
|
||||
$flags = registry()->get('flextype.settings.serializers.json.decode.flags');
|
||||
@@ -109,14 +109,15 @@ class Json
|
||||
/**
|
||||
* Get Cache ID for JSON.
|
||||
*
|
||||
* @param string $input Input.
|
||||
* @param string $input Input.
|
||||
* @param string $string String to append to the Cache ID.
|
||||
*
|
||||
* @return string Cache ID.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getCacheID(string $input): string
|
||||
public function getCacheID(string $input, string $string = ''): string
|
||||
{
|
||||
return strings('json' . $input)->hash()->toString();
|
||||
return strings('json' . $input . $string . registry()->get('flextype.settings.serializers.json.decode.cache.string'))->hash()->toString();
|
||||
}
|
||||
}
|
||||
|
@@ -75,7 +75,7 @@ class Json5
|
||||
*/
|
||||
public function decode(string $input)
|
||||
{
|
||||
$cache = registry()->get('flextype.settings.serializers.json5.decode.cache');
|
||||
$cache = registry()->get('flextype.settings.serializers.json5.decode.cache.enabeled');
|
||||
$assoc = registry()->get('flextype.settings.serializers.json5.decode.assoc');
|
||||
$depth = registry()->get('flextype.settings.serializers.json5.decode.depth');
|
||||
$flags = registry()->get('flextype.settings.serializers.json5.decode.flags');
|
||||
@@ -103,14 +103,15 @@ class Json5
|
||||
/**
|
||||
* Get Cache ID for JSON5.
|
||||
*
|
||||
* @param string $input Input.
|
||||
* @param string $input Input.
|
||||
* @param string $string String to append to the Cache ID.
|
||||
*
|
||||
* @return string Cache ID.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getCacheID(string $input): string
|
||||
public function getCacheID(string $input, string $string = ''): string
|
||||
{
|
||||
return strings('json5' . $input)->hash()->toString();
|
||||
return strings('json5' . $input . $string . registry()->get('flextype.settings.serializers.json5.decode.cache.string'))->hash()->toString();
|
||||
}
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ class Neon
|
||||
*/
|
||||
public function decode(string $input)
|
||||
{
|
||||
$cache = registry()->get('flextype.settings.serializers.neon.decode.cache');
|
||||
$cache = registry()->get('flextype.settings.serializers.neon.decode.cache.enabled');
|
||||
|
||||
$decode = static function (string $input) {
|
||||
try {
|
||||
@@ -87,14 +87,15 @@ class Neon
|
||||
/**
|
||||
* Get Cache ID for neon.
|
||||
*
|
||||
* @param string $input Input.
|
||||
* @param string $input Input.
|
||||
* @param string $string String to append to the Cache ID.
|
||||
*
|
||||
* @return string Cache ID.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getCacheID(string $input): string
|
||||
public function getCacheID(string $input, string $string = ''): string
|
||||
{
|
||||
return strings('neon' . $input)->hash()->toString();
|
||||
return strings('neon' . $input . $string . registry()->get('flextype.settings.serializers.neon.decode.cache.string'))->hash()->toString();
|
||||
}
|
||||
}
|
||||
|
@@ -60,7 +60,7 @@ class PhpArray
|
||||
*/
|
||||
public function decode(string $input)
|
||||
{
|
||||
$cache = registry()->get('flextype.settings.serializers.phparray.decode.cache');
|
||||
$cache = registry()->get('flextype.settings.serializers.phparray.decode.cache.enabled');
|
||||
|
||||
$decode = static function (string $input) {
|
||||
try {
|
||||
@@ -91,14 +91,15 @@ class PhpArray
|
||||
/**
|
||||
* Get Cache ID for phparray.
|
||||
*
|
||||
* @param string $input Input.
|
||||
* @param string $input Input.
|
||||
* @param string $string String to append to the Cache ID.
|
||||
*
|
||||
* @return string Cache ID.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getCacheID(string $input): string
|
||||
public function getCacheID(string $input, string $string = ''): string
|
||||
{
|
||||
return strings('phparray' . $input)->hash()->toString();
|
||||
return strings('phparray' . $input . $string . registry()->get('flextype.settings.serializers.phparray.decode.cache.string'))->hash()->toString();
|
||||
}
|
||||
}
|
||||
|
@@ -82,7 +82,7 @@ class Yaml
|
||||
*/
|
||||
public function decode(string $input)
|
||||
{
|
||||
$cache = registry()->get('flextype.settings.serializers.yaml.decode.cache');
|
||||
$cache = registry()->get('flextype.settings.serializers.yaml.decode.cache.enabled');
|
||||
$flags = registry()->get('flextype.settings.serializers.yaml.decode.flags');
|
||||
$native = registry()->get('flextype.settings.serializers.yaml.decode.native');
|
||||
|
||||
@@ -134,14 +134,15 @@ class Yaml
|
||||
/**
|
||||
* Get Cache ID for YAML.
|
||||
*
|
||||
* @param string $input Input.
|
||||
* @param string $input Input.
|
||||
* @param string $string String to append to the Cache ID.
|
||||
*
|
||||
* @return string Cache ID.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getCacheID(string $input): string
|
||||
public function getCacheID(string $input, string $string = ''): string
|
||||
{
|
||||
return strings('yaml' . $input)->hash()->toString();
|
||||
return strings('yaml' . $input . $string . registry()->get('flextype.settings.serializers.yaml.decode.cache.string'))->hash()->toString();
|
||||
}
|
||||
}
|
||||
|
@@ -199,7 +199,7 @@ if (registry()->get('flextype.settings.output_buffering')) {
|
||||
}
|
||||
|
||||
// Add Router Cache
|
||||
if (registry()->get('flextype.settings.router.cache')) {
|
||||
if (registry()->get('flextype.settings.router.cache.enabled')) {
|
||||
filesystem()->directory(PATH_TMP . '/routes')->ensureExists(0755, true);
|
||||
app()->getRouteCollector()->setCacheFile(PATH_TMP . '/routes/routes.php');
|
||||
}
|
||||
|
@@ -74,6 +74,8 @@ errors:
|
||||
# Entries
|
||||
entries:
|
||||
directory: 'entries'
|
||||
cache:
|
||||
string: ""
|
||||
vars:
|
||||
debug: false
|
||||
expressions:
|
||||
@@ -432,7 +434,8 @@ router:
|
||||
|
||||
# Caching the FastRoute routes for better perfomance.
|
||||
# Set to true to enable the FastRoute cache system.
|
||||
cache: true
|
||||
cache:
|
||||
enabled: true
|
||||
|
||||
# Set to true to enable the Flextype CLI Application
|
||||
cli: true
|
||||
@@ -505,7 +508,9 @@ slugify:
|
||||
serializers:
|
||||
json:
|
||||
decode:
|
||||
cache: true
|
||||
cache:
|
||||
enabled: true
|
||||
string: ""
|
||||
assoc: true
|
||||
depth: 512
|
||||
flags: 0
|
||||
@@ -514,7 +519,9 @@ serializers:
|
||||
depth: 512
|
||||
json5:
|
||||
decode:
|
||||
cache: true
|
||||
cache:
|
||||
enabled: true
|
||||
string: ""
|
||||
assoc: true
|
||||
depth: 512
|
||||
flags: 0
|
||||
@@ -523,7 +530,9 @@ serializers:
|
||||
depth: 512
|
||||
yaml:
|
||||
decode:
|
||||
cache: true
|
||||
cache:
|
||||
enabled: true
|
||||
string: ""
|
||||
native: true
|
||||
flags: 0
|
||||
encode:
|
||||
@@ -532,7 +541,10 @@ serializers:
|
||||
flags: 0
|
||||
frontmatter:
|
||||
decode:
|
||||
cache: true
|
||||
cache:
|
||||
enabled: true
|
||||
string: ""
|
||||
cache_id_string: ""
|
||||
header:
|
||||
serializer: yaml
|
||||
allowed: ['yaml', 'json', 'json5', 'neon']
|
||||
@@ -542,13 +554,17 @@ serializers:
|
||||
allowed: ['yaml', 'json', 'json5', 'neon']
|
||||
neon:
|
||||
decode:
|
||||
cache: true
|
||||
cache:
|
||||
enabled: true
|
||||
string: ""
|
||||
encode:
|
||||
blockMode: false
|
||||
indentation: "\t"
|
||||
phparray:
|
||||
decode:
|
||||
cache: true
|
||||
cache:
|
||||
enabled: true
|
||||
string: ""
|
||||
encode:
|
||||
wrap: true
|
||||
|
||||
@@ -581,7 +597,9 @@ serializers:
|
||||
# - markdown.commonmark.slug_normalizer.max_length: Limits the size of generated slugs (defaults to 255 characters)
|
||||
parsers:
|
||||
markdown:
|
||||
cache: true
|
||||
cache:
|
||||
enabled: true
|
||||
string: ""
|
||||
commonmark:
|
||||
renderer:
|
||||
block_separator: "\n"
|
||||
@@ -599,7 +617,10 @@ parsers:
|
||||
slug_normalizer:
|
||||
max_length: 255
|
||||
textile:
|
||||
cache: true
|
||||
cache:
|
||||
enabled: true
|
||||
string: ""
|
||||
cache_id_string: ""
|
||||
restricted: false
|
||||
document_type: 'xhtml'
|
||||
document_root_directory: ''
|
||||
@@ -614,7 +635,10 @@ parsers:
|
||||
symbol: []
|
||||
dimensionless_images: true
|
||||
shortcodes:
|
||||
cache: true
|
||||
cache:
|
||||
enabled: true
|
||||
string: ""
|
||||
cache_id_string: ""
|
||||
opening_tag: "("
|
||||
closing_tag: ")"
|
||||
closing_tag_marker: "/"
|
||||
|
Reference in New Issue
Block a user