2017 © Pedro Peláez
 

wordpress-plugin wp-redis-group-cache

A plugin extending the Redis Object Cache for WordPress with a group cache functionality

image

devgeniem/wp-redis-group-cache

A plugin extending the Redis Object Cache for WordPress with a group cache functionality

  • Tuesday, December 19, 2017
  • by devgeniem
  • Repository
  • 16 Watchers
  • 0 Stars
  • 626 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 12 Versions
  • 15 % Grown

The README.md

geniem-github-banner, (*1)

WP Redis Group Cache

Latest Stable Version Total Downloads Latest Unstable Version License, (*2)

This WordPress mu-plugin enables group caching for sites using the Redis Object Cache for WordPress dropin., (*3)

Installation

Install with composer:, (*4)

$ composer require devgeniem/wp-redis-group-cache

OR add it into your composer.json:, (*5)

{
  "require": {
    "devgeniem/wp-redis-group-cache": "^3.0.0"
  }
}

Functionalities

Creating the cache group

Defining a group for WP Object Cache items enables simultaneous cache invalidation for a set of cache items. See the codex for further information on setting the group key. The following functions create the object cache functionality by hooking to the Redis Object Cache dropin:, (*6)

add_to_group, (*7)

This function is hooked to the cache setting with the wp_cache_set function. If a group key is set for wp_cache_set, the cache key is pushed into a Redis hash list mapped by the group key., (*8)

delete_from_group, (*9)

This function is hooked to the cache deletion with the wp_cache_delete function. If a group key is set for wp_cache_delete, the specified item key is removed from the group list. This ensures the group only has keys that actually exist in the object cache., (*10)

Invalidating a cache group

delete_group, (*11)

This function deletes all data related to a group key by first fetching all keys and deleting them from Redis and then deleting the Redis hash list of the group., (*12)

Usage:, (*13)

\Geniem\GroupCache::delete_group( $group_key );

Excluding custom or including default groups to caching

The Redis dropin automatically caches all data stored with WordPress Object Cache into Redis. If you want to modify which groups are stored you can use the two filters geniem/cache/no_group_cache/blacklist and geniem/cache/no_group_cache., (*14)

Modifying the blacklist

If you want to include some default groups like acf or transient or exclude custom ones for example from plugins that use it, you can use the geniem/cache/no_group_cache/blacklist filter to modify an array of blacklisted groups., (*15)

function group_cache_blacklist( array $groups ) : array {
    $groups[] = 'customgroup';
    return $groups;
}
add_filter( 'geniem/cache/no_group_cache/blacklist', 'group_cache_blacklist', 1, 1 );

Exluded groups by default

classes/cache.php, (*16)

More specific selection if a group should be excluded

You can do a more direct check if a group should be exluded by using the geniem/cache/no_group_cache filter. Note this is applied after the blacklist check, so if the group is already on the blacklist this will not be checked., (*17)

function no_group_cache( string $group, string $key ) : bool {
    if ( 'no_caching_key' === $group ) {
        return true;
    } else {
        return false;
    }
}
add_filter( 'geniem/cache/no_group_cache', 'no_group_cache', 1, 2 );

Note that this does not disable the initial key-value caching!, (*18)

Example

See this Github gist for a usage example., (*19)

Maintainers

@villesiltala, (*20)

License

GPLv3, (*21)

The Versions

19/12 2017

dev-store-value

dev-store-value

A plugin extending the Redis Object Cache for WordPress with a group cache functionality

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress cache redis object cache

06/06 2017

dev-master

9999999-dev

A plugin extending the Redis Object Cache for WordPress with a group cache functionality

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress cache redis object cache

06/06 2017

2.0.1

2.0.1.0

A plugin extending the Redis Object Cache for WordPress with a group cache functionality

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress cache redis object cache

06/06 2017

2.0.0

2.0.0.0

A plugin extending the Redis Object Cache for WordPress with a group cache functionality

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress cache redis object cache

02/06 2017

1.0.3

1.0.3.0

A plugin extending the Redis Object Cache for WordPress with a group cache functionality

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress cache redis object cache

09/03 2017

1.0.2

1.0.2.0

A plugin extending the Redis Object Cache for WordPress with a group cache functionality

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress cache redis object cache

27/01 2017

1.0.1

1.0.1.0

A plugin extending the Redis Object Cache for WordPress with a group cache functionality

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress cache redis object cache

27/01 2017

dev-license-and-maintainer

dev-license-and-maintainer

A plugin extending the Redis Object Cache for WordPress with a group cache functionality

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress cache redis object cache

27/01 2017

1.0.0

1.0.0.0

A plugin extending the Redis Object Cache for WordPress with a group cache functionality

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress cache redis object cache

09/12 2016

0.0.3

0.0.3.0

A plugin extending the Redis Object Cache for WordPress with a group cache functionality

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress cache redis object cache

08/12 2016

0.0.2

0.0.2.0

A plugin extending the Redis Object Cache for WordPress with a group cache functionality

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress cache redis object cache

08/12 2016

0.0.1

0.0.1.0

A plugin extending the Redis Object Cache for WordPress with a group cache functionality

  Sources   Download

GPL-3.0

The Requires

 

plugin wordpress cache redis object cache