WPDev.one
Core Function
View Source on Trac ↗

wp_cache_add()

wp_cache_add( mixed $key, mixed $data, mixed $group = '', mixed $expire = 0 )

Adds data to the cache, if the cache key doesn't already exist.

Parameters 4 required

Name / Type Description
(int

| string) $key The cache key to use for retrieval later.

Required
$data
mixed

The data to add to the cache.

Required
string

$group Optional. The group to add the cache to. Enables the same key to be used across groups. Default empty.

Required
int

$expire Optional. When the cache data should expire, in seconds. Default 0 (no expiration).

Required

Return Value

(bool)
True on success, false if cache key and group already exist.

Function Information

Since Version
2.0.0
Source File
wp-includes/cache.php
Advertisement