<commit_before># SilverStripe Cache Include

[![Build Status](https://travis-ci.org/heyday/silverstripe-cacheinclude.svg?branch=master)](https://travis-ci.org/heyday/silverstripe-cacheinclude)

Template caching based on urls not DB queries.

## Features

* Cache keys are built from information available in request object (means no DB calls)
* Invalidation hooks for when DataObject's are modified
* Uses `doctrine/cache` library, providing many cache backends
* Uses Symfony Expression language for fine-grained invalidation control
* Support for `<% cache_include 'TemplateName' %>` syntax in templates
* Support for `<% cache %><% end_cache %>` syntax in templates
* A full request cache that includes the ability to substitute security tokens
* Highly customisable
* CacheInclude Manager for easy cache management https://github.com/heyday/silverstripe-cacheinclude-manager/

For a SilverStripe `2.4` compatible version, see the `2.0.4` tag.

## Installation

```bash
$ composer require heyday/silverstripe-cacheinclude:~4.0
```

## How to use

### Enabling

To  be able to invalidate caches from DataObject writes, add the `InvalidationExtension`:

1. Create a config file `mysite/_config/caching.yml`
2. Add the following to the yml file

```yml
---
After: 'silverstripe-cacheinclude/*'
---
DataObject:
  extensions:
    - Heyday\CacheInclude\SilverStripe\InvalidationExtension
```

### Template Usage
<commit_msg>update readme composer require example for 5.x<commit_after># SilverStripe Cache Include

[![Build Status](https://travis-ci.org/heyday/silverstripe-cacheinclude.svg?branch=master)](https://travis-ci.org/heyday/silverstripe-cacheinclude)

Template caching based on urls not DB queries.

## Features

* Cache keys are built from information available in request object (means no DB calls)
* Invalidation hooks for when DataObject's are modified
* Uses `doctrine/cache` library, providing many cache backends
* Uses Symfony Expression language for fine-grained invalidation control
* Support for `<% cache_include 'TemplateName' %>` syntax in templates
* Support for `<% cache %><% end_cache %>` syntax in templates
* A full request cache that includes the ability to substitute security tokens
* Highly customisable
* CacheInclude Manager for easy cache management https://github.com/heyday/silverstripe-cacheinclude-manager/

For a SilverStripe `2.4` compatible version, see the `2.0.4` tag.

## Installation

```bash
$ composer require heyday/silverstripe-cacheinclude:~5.0
```

## How to use

### Enabling

To  be able to invalidate caches from DataObject writes, add the `InvalidationExtension`:

1. Create a config file `mysite/_config/caching.yml`
2. Add the following to the yml file

```yml
---
After: 'silverstripe-cacheinclude/*'
---
DataObject:
  extensions:
    - Heyday\CacheInclude\SilverStripe\InvalidationExtension
```

### Template Usage

{'fraction_non_alphanumeric': 0.10121739130434783, 'fraction_numerical': 0.006608695652173913, 'mean_word_length': 5.042016806722689, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3884518', 'n_tokens_mistral': 871, 'n_tokens_neox': 829, 'n_words': 284}