wnipun/wp-memoize

Simple disk based caching library for WordPress builds that use roots.io Bedrock.

1.0.3 2023-03-26 13:22 UTC

This package is auto-updated.

Last update: 2025-07-26 18:19:55 UTC


README

Simple disk based caching library for WordPress builds that use roots.io Bedrock.

Installation

Memoize require >= 8.1

composer require wnipun/wp-memoize

Usage

WP_Query results can be cached using the following code.

use wnipun\Memoize\Memoize;

$bulletin = Memoize::query([
    'post_type' => 'bulletin',
    'posts_per_page' => 3
  ])
  ->withFields([
    'bulletin_agency',
    'bulletin_thumbnail'
  ])
  ->withTaxonomies([
    'bulletin_category'
  ])
  ->cache();
  • query - Accepts WP_Query arguments
  • withFields - Eager load ACF fields
  • withTaxonomies - Eager load taxonomies

Clear cache

There are two methods available to clear cache.

  // Clear everything
  Memoize::clear();

  // Clear provided post types
  Memoize::clear('bulletin', 'news');