Skip to content

Commit 05424ec

Browse files
petitphpschlessera
authored andcommitted
Add missing expiration option for patch cache command
1 parent bd13459 commit 05424ec

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Cache_Command.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,12 @@ public function pluck( $args, $assoc_args ) {
494494
* default: default
495495
* ---
496496
*
497+
* [--expiration=<expiration>]
498+
* : Define how long to keep the value, in seconds. `0` means as long as possible.
499+
* ---
500+
* default: 0
501+
* ---
502+
*
497503
* [--format=<format>]
498504
* : The serialization format for the value.
499505
* ---
@@ -506,6 +512,7 @@ public function pluck( $args, $assoc_args ) {
506512
public function patch( $args, $assoc_args ) {
507513
list( $action, $key ) = $args;
508514
$group = Utils\get_flag_value( $assoc_args, 'group' );
515+
$expiration = Utils\get_flag_value( $assoc_args, 'expiration' );
509516

510517
$key_path = array_map( function ( $key ) {
511518
if ( is_numeric( $key ) && ( $key === (string) intval( $key ) ) ) {
@@ -545,7 +552,7 @@ public function patch( $args, $assoc_args ) {
545552
if ( $patched_value === $old_value ) {
546553
WP_CLI::success( "Value passed for cache key '$key' is unchanged." );
547554
} else {
548-
if ( wp_cache_set( $key, $patched_value, $group ) ) {
555+
if ( wp_cache_set( $key, $patched_value, $group, $expiration ) ) {
549556
WP_CLI::success( "Updated cache key '$key'." );
550557
} else {
551558
WP_CLI::error( "Could not update cache key '$key'." );

0 commit comments

Comments
 (0)