function drush_cache_command_set

8.0.x cache.drush.inc drush_cache_command_set($cid = NULL, $data = '', $bin = NULL, $expire = NULL, $tags = array())
6.x cache.drush.inc drush_cache_command_set($cid = NULL, $data = '', $bin = NULL, $expire = CACHE_PERMANENT)
7.x cache.drush.inc drush_cache_command_set($cid = NULL, $data = '', $bin = NULL, $expire = NULL, $tags = array())
5.x cache.drush.inc drush_cache_command_set($cid = NULL, $data = '', $bin = NULL, $expire = CACHE_PERMANENT)
master cache.drush.inc drush_cache_command_set($cid = NULL, $data = '', $bin = NULL, $expire = NULL, $tags = array())

Set an object in the cache.

Parameters

$cid: The cache ID of the object to fetch.

$data: The data to save to the cache, or '-' to read from STDIN.

$bin: Optional parameter to specify a specific bin to fetch from.

$expire: Optional parameter to specify the expiry of the cached object.

1 string reference to 'drush_cache_command_set'
cache_drush_command in commands/core/cache.drush.inc
Implementation of hook_drush_command().

File

commands/core/cache.drush.inc, line 157

Code

function drush_cache_command_set($cid = NULL, $data = '', $bin = NULL, $expire = CACHE_PERMANENT) {
  if (!$bin) {
    $bin = 'cache';
  }

  if ($data == '-') {
    $data = stream_get_contents(STDIN);
  }

  // Now, we parse the object.
  switch (drush_get_option('format', 'string')) {
    case 'json':
      $data = drush_json_decode($data);
      break;
  }

  if (drush_get_option('cache-get')) {
    $data = $data->data;
  }

  cache_set($cid, $data, $bin, $expire);
}