Timed_Option::set( string $key, mixed $value, int $expiration = DAY_IN_SECONDS )
Update the value of a timed option on the database and on local cache.
Contents
Parameters
- $key
-
(string) (Required) Key for this option.
- $value
-
(mixed) (Required) Value stored for this option.
- $expiration
-
(int) (Optional) Expiration in seconds for this timed option.
Default value: DAY_IN_SECONDS
Return
(bool)
Source
File: src/Common/Storage/Timed_Option.php
public function set( $key, $value, int $expiration = DAY_IN_SECONDS ): bool { $key = (string) $key; $data = [ 'key' => $key, 'value' => $value, 'expiration' => time() + $expiration, ]; $this->data[ $key ] = $data; $updated = true; if ( $this->is_active() ) { $updated = update_option( $this->get_option_name( $key ), $data, true ); } return $updated; }
Changelog
Version | Description |
---|---|
5.0.6 | Introduced. |