Table_Cache extends View_Cache Uses Resolves_Data_Source

Handles the caching for post tables.

There are 2 types of caching used:

  • Table caching: this is used for lazy load tables where we need to initially create the table, then later fetch the table by ID to fetch the actual posts.
  • Data caching: this is used to cache the data in a table, and is enabled or disabled using the 'cache' option in the shortcode, or from the plugin settings.
Tags
author

Barn2 Plugins [email protected]

license

GPL-3.0

copyright

Barn2 Media Ltd

Table of Contents

__construct()  : mixed
Constructor.
add_table()  : mixed
Adds a table to the cache.
delete_data()  : mixed
Delete cached data.
get_cached_table_ids()  : array<string|int, mixed>
Get all cached view IDs.
get_data()  : mixed|false
Get cached data.
get_table()  : Posts_Table|false
Gets a table from the cache.
load_from_cache()  : Posts_Table|false
Legacy alias for get_table().
update_data()  : mixed
Update cached data.
update_table()  : mixed
Update view configuration in cache.
get_table_cache_key()  : string
Get the view cache key.
table_caching_enabled()  : bool
Check if view caching is enabled.

Methods

__construct()

Constructor.

public __construct(string $id, Table_Args $args, Table_Query $query) : mixed

Maintains the legacy Table_Cache constructor signature.

Parameters
$id : string

The table ID.

$args : Table_Args

Table args.

$query : Table_Query

Table query.

Tags
Return values
mixed

add_table()

Adds a table to the cache.

public add_table([array<string|int, mixed> $args = [] ]) : mixed
Parameters
$args : array<string|int, mixed> = []

The arguments for the table.

Tags
deprecated
4.0

Use add_view() instead.

Return values
mixed

delete_data()

Delete cached data.

public delete_data() : mixed
Tags
Return values
mixed

get_cached_table_ids()

Get all cached view IDs.

public static get_cached_table_ids([string $prefix = '' ]) : array<string|int, mixed>
Parameters
$prefix : string = ''

Optional prefix to match.

Tags
deprecated
4.0

Use get_cached_view_ids() instead.

Return values
array<string|int, mixed>

Array of view IDs.

get_data()

Get cached data.

public get_data() : mixed|false
Tags
Return values
mixed|false

get_table()

Gets a table from the cache.

public static get_table(string $id) : Posts_Table|false
Parameters
$id : string

The ID of the table to retrieve.

Tags
deprecated
4.0

Use View_Factory::fetch() instead.

Return values
Posts_Table|false

The table object or false if not found.

load_from_cache()

Legacy alias for get_table().

public static load_from_cache(string $id) : Posts_Table|false
Parameters
$id : string

The table ID.

Tags
deprecated
4.0

Use get_table().

Return values
Posts_Table|false

update_data()

Update cached data.

public update_data(mixed $data) : mixed
Parameters
$data : mixed

Data to cache.

Tags
Return values
mixed

update_table()

Update view configuration in cache.

public update_table([bool $update_totals = false ]) : mixed
Parameters
$update_totals : bool = false

Whether to update cached totals.

Tags
deprecated
4.0

Use update_view() instead.

Return values
mixed

get_table_cache_key()

Get the view cache key.

protected get_table_cache_key() : string
Tags
deprecated
4.0

Use get_view_cache_key() instead.

Return values
string

The cache key.

table_caching_enabled()

Check if view caching is enabled.

protected table_caching_enabled() : bool
Tags
deprecated
4.0

Use view_caching_enabled() instead.

Return values
bool

True if enabled.

Search results