Download the PHP package humanmade/hm-swr-cache without Composer

On this page you can find all versions of the php package humanmade/hm-swr-cache. 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 hm-swr-cache

HM SWR Cache

A soft expiring cache with background updating is a specialized caching strategy that allows cached data to remain available even after the expiration period. With regular caching, data becomes unavailable or leads to a 'cache miss' as soon as it expires. This can be costly, particularly with complex data fetching operations that require significant time.

In a soft expiring cache, when the cache period expires, the cached data remains accessible while a background update operation occurs. During this time, the user or application continues to see the stale cached data until the new updated data is ready. This approach ensures data is always available for end consumers with minimized latency from cache rebuild, providing a continuously smooth experience. This is also called a stale-while-revalidate cache strategy, thus the name.

Note: As the cache is updated via a wp_schedule_single_event() call, using a scalable job system such as Cavalcade is recommended as the default WordPress pseudo-cron slows the page load running the scheduled event.

Requirements

Installation

Just install the plugin like any other plugin. Installation as a MU plugin is supported as well, and via composer

These commands configure Composer to use a custom Git repository for the hm-swr-cache package, add this package as a requirement without immediately installing it, and finally update and install the package from the source repository.

Usage

All that is needed is for you to create a callback function that will be called with $callback_args as the first parameter by a scheduled task that is triggered when the cache expires after $cache_expiry seconds.

The following code goes where you need to use the cached data. On the first request the cache will be empty and scheduled to be generated, so your implementation needs handle that event. After the first generation, there will either be stale or current data to display:

The callback is what you need to implement to generate the cacheable data, an array in the example below. You must return a WP_Error object in case of issues, this will generate an RuntimeException in the cron event, resulting in a cron log entry.

Internally a self-expiring and self-managed lock system ensures the callback is just processed once, avoiding race conditions. If, for whatever reason (for example due to a fatal error) the callback doesn't complete, then the lock self-expires in 1 minute.

Flushing the cache

Engineers can clear the cache as well as any locks by calling the cache_delete_group( $cache_group ) function, which might be useful after saving a settings page for example. The cachegroup should first be registrered for flushing using register_cache_group( $cache_group ) before it can be flushed.

Difference with other plugins

  1. WP-TLC-Transients In contrast to WP-TLC-Transients, HM Swr Cache is not hitting the database in any circumstance as both the lock, cached data and cache expiry are all stored using wp_cache functions. The syntax is also quite different.

I think that's it!


All versions of hm-swr-cache with dependencies

PHP Build Version
Package Version
No informations.
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 humanmade/hm-swr-cache contains the following files

Loading the files please wait ....