diff --git a/src/flextype/core/Entries/Entries.php b/src/flextype/core/Entries/Entries.php index bb870ec2..1d265b39 100755 --- a/src/flextype/core/Entries/Entries.php +++ b/src/flextype/core/Entries/Entries.php @@ -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(); } /** diff --git a/src/flextype/core/Parsers/Markdown.php b/src/flextype/core/Parsers/Markdown.php index f0ccaed0..6c97cfc2 100644 --- a/src/flextype/core/Parsers/Markdown.php +++ b/src/flextype/core/Parsers/Markdown.php @@ -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(); } } diff --git a/src/flextype/core/Parsers/Shortcodes.php b/src/flextype/core/Parsers/Shortcodes.php index f1da3acb..bd9a8800 100644 --- a/src/flextype/core/Parsers/Shortcodes.php +++ b/src/flextype/core/Parsers/Shortcodes.php @@ -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(); } } diff --git a/src/flextype/core/Parsers/Textile.php b/src/flextype/core/Parsers/Textile.php index 2621e32a..d41ef650 100644 --- a/src/flextype/core/Parsers/Textile.php +++ b/src/flextype/core/Parsers/Textile.php @@ -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(); } } diff --git a/src/flextype/core/Serializers/Frontmatter.php b/src/flextype/core/Serializers/Frontmatter.php index 51af4b06..b18f56f9 100644 --- a/src/flextype/core/Serializers/Frontmatter.php +++ b/src/flextype/core/Serializers/Frontmatter.php @@ -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(); } } diff --git a/src/flextype/core/Serializers/Json.php b/src/flextype/core/Serializers/Json.php index 281bedfd..c7d9d26d 100644 --- a/src/flextype/core/Serializers/Json.php +++ b/src/flextype/core/Serializers/Json.php @@ -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(); } } diff --git a/src/flextype/core/Serializers/Json5.php b/src/flextype/core/Serializers/Json5.php index 0b864079..a2769cc3 100644 --- a/src/flextype/core/Serializers/Json5.php +++ b/src/flextype/core/Serializers/Json5.php @@ -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(); } } diff --git a/src/flextype/core/Serializers/Neon.php b/src/flextype/core/Serializers/Neon.php index 11c84b99..2ca009e6 100644 --- a/src/flextype/core/Serializers/Neon.php +++ b/src/flextype/core/Serializers/Neon.php @@ -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(); } } diff --git a/src/flextype/core/Serializers/PhpArray.php b/src/flextype/core/Serializers/PhpArray.php index 353c1e0c..c42f2b4e 100644 --- a/src/flextype/core/Serializers/PhpArray.php +++ b/src/flextype/core/Serializers/PhpArray.php @@ -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(); } } diff --git a/src/flextype/core/Serializers/Yaml.php b/src/flextype/core/Serializers/Yaml.php index a25d05b4..11aaba18 100644 --- a/src/flextype/core/Serializers/Yaml.php +++ b/src/flextype/core/Serializers/Yaml.php @@ -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(); } } diff --git a/src/flextype/flextype.php b/src/flextype/flextype.php index b881db88..287305ed 100644 --- a/src/flextype/flextype.php +++ b/src/flextype/flextype.php @@ -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'); } diff --git a/src/flextype/settings.yaml b/src/flextype/settings.yaml index 4f6074dd..319b6315 100644 --- a/src/flextype/settings.yaml +++ b/src/flextype/settings.yaml @@ -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: "/"