Download the PHP package alleyinteractive/cache-collector without Composer

On this page you can find all versions of the php package alleyinteractive/cache-collector. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cache-collector

Cache Collector

Coding Standards Testing Suite

Dynamic cache key collector for easy purging.

Background

One common problem with large WordPress sites that utilize Memcache is the problems that arise when trying to purge cache keys that are dynamically generated. For example, if a cache key is the hash of a remote request. You would need to calculate the hashed cache key to properly purge it from the cache. Another common problem would be trying to purge all the cache keys in a specific group (Memcache doesn't support group purging).

Cache Collector solves this by storing cache/transient keys in collections. These collections can then be purged in a single command. Here's a real-world use case:

When viewing a post, the post's related posts are fetched from a remote source and displayed to the user. This operation is expensive due to the remote request and needs to be cached. When the post is updated, the related post cache needs to be flushed as well.

Enter Cache Collector. When the post is updated, the related post cache key is added to a collection. When the post is updated, the cache key that is connected to the post will automatically be purged.

To flip this around, say the remote data source is having issues and you need to flush all the related post cache keys. You can do this by purging the "related posts" cache collection. This stores all the cache keys for all related posts. In one command you can purge an entire cache group without having to calculate the cache key for each.

Installation

You can install the package via composer:

Usage

Activate the plugin in WordPress and use the below methods to interface with the cache collector.

Registering Keys

One important note when registering cache keys: registering a key should only be done when the cache/transient is stored. When the key is stored the system will set an expiration date for the key to be eventually purged from the collection if unused. To prevent continually updating the keys in the collection and degrading site performance, the key should only be registered when the cache/transient is stored. The cache collector will eventually remove the key from the collection when it expires.

TL;DR: Register the key only when the cache/transient is stored. Don't register it on every page load.

Register a Key in a Cache Collection

The plugin also provides cache_collector_register_transient_key() and cache_collector_register_cache_key() to make it easier to register keys for a transient/cache without having to specify the $type argument.

Purging a Cache Collection

Purge all the cache entries in a collection.

Registering a Key Related to a Post

A post cache collection is a collection of cache keys related to a post. When a post is updated, the post's cache collection is automatically purged. This allows you to purge all of the cache keys related to a post at once.

Purging a Post's Cache Collection

Purge a cache collection related to a post.

Registering a Key Related to a Term

Purging a Term's Cache Collection

Full Example

The following example shows how to use the cache collector to register a cache key for future purging.

Now we can purge the cache collection whenever we need to:

We can also purge this with the WP-CLI command included with the plugin:

Testing

Run composer test to run tests against PHPUnit and the PHP code in the plugin.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

This project is actively maintained by Alley Interactive. Like what you see? Come work with us.

License

The GNU General Public License (GPL) license. Please see License File for more information.


All versions of cache-collector with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package alleyinteractive/cache-collector contains the following files

Loading the files please wait ....