@@ -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