wp_cache_set( int|string $key, mixed $data, string $group = '', int $expire = 0 ): bool
- Since
- 2.0.0
- Source
wp-includes/cache.php:108
Saves the data to the cache.
Description
Differs from wp_cache_add() and wp_cache_replace() in that it will always write data.
Parameters
$keyint|string- The cache key to use for retrieval later.
$datamixed- The contents to store in the cache.
$groupstringoptional- Where to group the cache contents. Enables the same key to be used across groups. Default empty.Default:
'' $expireintoptional- When to expire the cache contents, in seconds. Default 0 (no expiration).Default:
0
Return
bool- True on success, false on failure.
Used by · 42
- Twenty_Eleven_Ephemera_Widget::widget()Outputs the HTML for this widget.
- WP_AI_Client_Cache::set()Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
- WP_Customize_Manager::find_changeset_post_id()Finds the changeset post ID for a given changeset UUID.
- WP_Embed::find_oembed_post_id()Finds the oEmbed cache post ID for a given cache key.
- WP_MS_Sites_List_Table::column_users()Handles the users column output.
- WP_Privacy_Requests_Table::get_request_counts()Counts the number of requests for each status.
- WP_Site::get_details()Retrieves the details for this site.
- WP_Textdomain_Registry::get_language_files_from_path()Retrieves translation files from the specified path.
- _get_last_post_time()Gets the timestamp of the last time any post was modified or published.
- _wp_image_editor_choose()Tests which editors are capable of supporting the request.
- add_network_option()Adds a new network option.
- add_option()Adds a new option.
Show all 42
- delete_network_option()Removes a network option by name.
- delete_option()Removes an option by name. Prevents removal of protected WordPress options.
- get_blog_details()Retrieves the details for a blog from the blogs table and blog options.
- get_blog_id_from_url()Gets a blog's numeric ID from its URL.
- get_bookmarks()Retrieves the list of bookmarks.
- get_calendar()Displays calendar with days that have posts as links.
- get_lastcommentmodified()Retrieves the date the last comment was modified.
- get_network_option()Retrieves a network's option value based on the option name.
- get_option()Retrieves an option value based on an option name.
- get_plugins()Checks the plugins directory and retrieve all plugin files with plugin data.
- is_blog_installed()Determines whether WordPress is already installed.
- is_object_in_term()Determines if the given object is associated with any of the given terms.
- set_site_transient()Sets/updates the value of a site transient.
- set_transient()Sets/updates the value of a transient.
- update_network_option()Updates the value of a network option that was already added.
- update_option()Updates the value of an option that was already added.
- wp_cache_set_last_changed()Sets last changed date for the specified cache group to now.
- wp_cache_set_multiple()Sets multiple values to the cache in one call.
- wp_cache_set_salted()Stores salted data in the cache.
- wp_count_attachments()Counts number of attachments for the mime type(s).
- wp_count_comments()Retrieves the total comment counts for the whole site or a single post.
- wp_count_posts()Counts number of posts of a post type and if user has permissions to view.
- wp_get_global_settings()Gets the settings resulting of merging core, theme, and user data.
- wp_get_global_styles_custom_css()Gets the global styles custom CSS from theme.json.
- wp_get_global_styles_svg_filters()Returns a string containing the SVGs to be referenced as filters (duotone).
- wp_get_global_stylesheet()Returns the stylesheet resulting of merging core, theme, and user data.
- wp_get_theme_data_template_parts()Returns the metadata for the template parts defined by the theme.
- wp_prime_network_option_caches()Primes specific network options into the cache with a single database query.
- wp_prime_option_caches()Primes specific options into the cache with a single database query.
- wp_set_option_autoload_values()Sets the autoload values for multiple options in the database.
Source
function wp_cache_set( $key, $data, $group = '', $expire = 0 ) { global $wp_object_cache; return $wp_object_cache->set( $key, $data, $group, (int) $expire );}History
Introduced in 2.0.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 tag, from
src/wp-includes/cache.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.