wp transient

Добавляет, получает и удаляет записи во временном кэше WordPress.

By default, the transient cache uses the WordPress database to persist values between requests. On a single site installation, values are stored in the wp_options table. On a multisite installation, values are stored in the wp_options or the wp_sitemeta table, depending on use of the --network flag.

When a persistent object cache drop-in is installed (e.g. Redis or Memcached), the transient cache skips the database and simply wraps the WP Object Cache.

Список команд Описание
wp transient get Возвращает временную опцию.
wp transient set Устанавливает временную опцию.
wp transient delete Удаляет временную опцию.
wp transient type Определяет тип применения временных опций.
wp transient list Список транзитов и их значений.

Примеры

# Set transient.
$ wp transient set sample_key "test data" 3600
Success: Transient added.

# Get transient.
$ wp transient get sample_key
test data

# Delete transient.
$ wp transient delete sample_key
Success: Transient deleted.

# Delete expired transients.
$ wp transient delete --expired
Success: 12 expired transients deleted from the database.

# Delete all transients.
$ wp transient delete --all
Success: 14 transients deleted from the database.

Исходный код команд


wp transient get

Возвращает временную опцию.

For a more complete explanation of the transient cache, including the network|site cache, please see docs for wp transient.

Использование

wp transient get {key} [--format={format}] [--network]

Можно указать Глобальные параметры и следующие:

{key}
Key for the transient.
[--format={format}]

Render output in a particular format.
По умолчанию: table
Может быть:

  • table
  • csv
  • json
  • yaml
[--network]
Get the value of a network|site transient. On single site, this is is a specially-named cache key. On multisite, this is a global cache (instead of local to the site).

Примеры

$ wp transient get sample_key
test data
$ wp transient get random_key
Warning: Transient with key "random_key" is not set.

Same as get_site_transient()

$ wp transient get random_key --network
Warning: Transient with key "random_key" is not set.

wp transient set

Устанавливает временную опцию.

<expiration> is the time until expiration, in seconds.

For a more complete explanation of the transient cache, including the network|site cache, please see docs for wp transient.

Использование

wp transient set {key} {value} [{expiration}] [--network]

Можно указать Глобальные параметры и следующие:

{key}
Key for the transient.
{value}
Value to be set for the transient.
[{expiration}]
Time until expiration, in seconds.
[--network]
Set the value of a network|site transient. On single site, this is is a specially-named cache key. On multisite, this is a global cache (instead of local to the site).

Примеры

$ wp transient set sample_key "test data" 3600
Success: Transient added.

wp transient delete

Удаляет временную опцию.

For a more complete explanation of the transient cache, including the network|site cache, please see docs for wp transient.

Использование

wp transient delete [{key}] [--network] [--all] [--expired]

Можно указать Глобальные параметры и следующие:

[{key}]
Key for the transient.
[--network]
Delete the value of a network|site transient. On single site, this is is a specially-named cache key. On multisite, this is a global cache (instead of local to the site).
[--all]
Delete all transients.
[--expired]
Delete all expired transients.

Примеры

# Delete transient.
$ wp transient delete sample_key
Success: Transient deleted.
# Delete expired transients.
$ wp transient delete --expired
Success: 12 expired transients deleted from the database.
# Delete all transients.
$ wp transient delete --all
Success: 14 transients deleted from the database.

wp transient type

Определяет тип применения временных опций.

Indicates whether the transients API is using an object cache or the options table.

For a more complete explanation of the transient cache, including the network|site cache, please see docs for wp transient.

Использование

wp transient type 

Примеры

$ wp transient type
Transients are saved to the wp_options table.

wp transient list

Список транзитов и их значений.

Использование

wp transient list [--search={pattern}] [--exclude={pattern}] [--network] [--unserialize] [--human-readable] [--fields={fields}] [--format={format}]

You can specify global options and the following:

[--search={pattern}]
Use wildcards ( * and ? ) to match transient name.
[--exclude={pattern}]
Pattern to exclude. Use wildcards ( * and ? ) to match transient name.
[--network]
Get the values of network|site transients. On single site, this is a specially-named cache key. On multisite, this is a global cache (instead of local to the site).
[--unserialize]
Unserialize transient values in output.
[--human-readable]
Human-readable output for expirations.
[--fields={fields}]
Limit the output to specific object fields.
[--format={format}]

The serialization format for the value.
Default: table
Can be:

  • table
  • json
  • csv
  • count
  • yaml

Available fields

This field will be displayed by default for each matching option:

  • name
  • value
  • expiration

Примеры

# List all transients
$ wp transient list
 +------+-------+---------------+
 | name | value | expiration    |
 +------+-------+---------------+
 | foo  | bar   | 39 mins       |
 | foo2 | bar2  | no expiration |
 | foo3 | bar2  | expired       |
 | foo4 | bar4  | 4 hours       |
 +------+-------+---------------+