PHPackages                             tourze/cache-strategy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. tourze/cache-strategy

ActiveLibrary[Caching](/categories/caching)

tourze/cache-strategy
=====================

Cache strategy interface

1.0.0(6mo ago)02721MITPHPCI passing

Since Apr 20Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/tourze/cache-strategy)[ Packagist](https://packagist.org/packages/tourze/cache-strategy)[ RSS](/packages/tourze-cache-strategy/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (1)

Cache Strategy
==============

[](#cache-strategy)

[English](README.md) | [中文](README.zh-CN.md)

[![Latest Version](https://camo.githubusercontent.com/2853f37ac72a689fc0681a640345f77fdf035c0230ad5918c45905139618b398/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f63616368652d73747261746567792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/cache-strategy)[![MIT License](https://camo.githubusercontent.com/10b05808f4f81bb3e5b8c5efca70ce5df72fb67ec8704b68d0bc1a0aadad3598/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f75727a652f63616368652d73747261746567792e7376673f7374796c653d666c61742d737175617265)](https://github.com/tourze/cache-strategy/blob/main/LICENSE)[![PHP Version Require](https://camo.githubusercontent.com/e4c6e5acf7e97418a3ea741c3b9b3c12318f8a5c5828290b43693d0de02571c0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f746f75727a652f63616368652d73747261746567792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/cache-strategy)[![Code Coverage](https://camo.githubusercontent.com/903ff81449236e89c2b8504884477520a6e35893643892762fe8c1ccffe8e0bf/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f746f75727a652f63616368652d73747261746567792e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/tourze/cache-strategy)

This package provides an interface for defining cache strategies that help determine which database queries should be cached.

Features
--------

[](#features)

- Simple interface for implementing custom cache strategies
- Built-in `NoCacheStrategy` implementation for basic usage
- Symfony DependencyInjection integration with autoconfiguration support
- No external dependencies other than Symfony DependencyInjection
- Compatible with PHP 8.2 and above

Installation
------------

[](#installation)

You can install this package using Composer:

```
composer require tourze/cache-strategy
```

### Requirements

[](#requirements)

- PHP 8.2 or higher
- Symfony DependencyInjection 6.4 or higher

Quick Start
-----------

[](#quick-start)

The core of this package is the `CacheStrategy` interface which provides a method to determine whether a query should be cached:

```
