Store data

@param mixed  $data        Object to store
@param string $id          Cache id
@param int    $timeToLive  Time to live in seconds
@return boolean true if no problem
9272
protected function _store($data, $id, $timeToLive)
    {
        if (zend_disk_cache_store($this->_options['namespace'] . '::' . $id,
                                  $data,
                                  $timeToLive) === false) {
            $this->_log('Store operation failed.');
            return false;
        }
        return true;
    }
293980
public function save($id, $data, $ttl = 60, $raw = FALSE)
	{
		return $this->{$this->_adapter}->save($this->key_prefix.$id, $data, $ttl, $raw);
	}
512326
public function setQueryCacheLifetime($timeToLive)
    {
        if ($timeToLive !== null) {
            $timeToLive = (int) $timeToLive;
        }

        $this->queryCacheTTL = $timeToLive;

        return $this;
    }
807570
public function touch($id, $extraLifetime)
    {
        if ($this->_options['compression']) {
            $flag = MEMCACHE_COMPRESSED;
        } else {
            $flag = 0;
        }
        $tmp = $this->_memcache->get($id);
        if (is_array($tmp)) {
            $data = $tmp[0];
            $mtime = $tmp[1];
            if (!isset($tmp[2])) {
                // because this record is only with 1.7 release
                // if old cache records are still there...
                return false;
            }
            $lifetime = $tmp[2];
            $newLifetime = $lifetime - (time() - $mtime) + $extraLifetime;
            if ($newLifetime <=0) {
                return false;
            }
            // #ZF-5702 : we try replace() first becase set() seems to be slower
            if (!($result = $this->_memcache->replace($id, array($data, time(), $newLifetime), $flag, $newLifetime))) {
                $result = $this->_memcache->set($id, array($data, time(), $newLifetime), $flag, $newLifetime);
            }
            return $result;
        }
        return false;
    }
559741
public function write($id, $data): bool
    {
        return $this->handler->set($this->prepareId($id), $data, (int)$this->ttl);
    }
730388
public static function set($id, $data, $cacheLife = 0)
    {
        $instance = self::getInstance();

        $time = time();
        $cache = array();
        $cache['contents'] = $data;
        $cache['expire'] = $cacheLife === 0 ? 0 : $time + $cacheLife;
        $cache['mtime'] = $time;

        $file = $instance->_file($id);

        return $instance->_filePutContents($file, $cache);
    }
294191
public function write($id, $data): bool
    {
        return Proxy\Cache::set($this->prepareId($id), $data, $this->ttl);
    }
254688
public function write($id, $data)
    {
        $session = \Doctrine::getTable($this->_tableName)->find($id);
        if (false === $session) {
            $session = new $this->_tableName();
            $session->{$this->_primaryKeyColumn} = $id;
        }

        $session->{$this->_dataColumn} = $data;
        $session->{$this->_lifetimeColumn} = $this->_lifetime;
        $session->{$this->_modifiedColumn} = time();

        if ($session->save()) {
            return true;
        }

        return false;
    }
1291612
public function write($id, $data)
    {
        $this->redis->set($this->prefix . $id, $data);

        $this->redis->expire($this->prefix . $id, $this->maxLifetime);

        return true;
    }
758533
public function save($id, $data, $ttl = 60, $raw = FALSE)
	{
		$contents = array(
			'time'		=> time(),
			'ttl'		=> $ttl,
			'data'		=> $data
		);

		if (write_file($this->_cache_path.$id, serialize($contents)))
		{
			chmod($this->_cache_path.$id, 0640);
			return TRUE;
		}

		return FALSE;
	}
262286
public function set($key, $value, $timeToLive = null) {
		$filename = $this->getFileName($key);
		//$this->log->trace("Storing value in cache: key '$key', value '".var_export($value, true)."'");
		if ($this->log) {
			if ($this->log instanceof LoggerInterface) {
				$this->log->info("Storing value in cache: key '{key}'", array('key'=>$key));
			} else {
				$this->log->trace("Storing value in cache: key '$key'");
			}
		}

        $oldUmask = umask(0);

		if (!is_writable($filename)) {
			if (!file_exists($this->getDirectory())) {
				mkdir($this->getDirectory(), 0777, true);
			}
		}
		
		if ($timeToLive == null) {
			if (empty($this->defaultTimeToLive)) {
				$timeOut = 0;
			} else {
				$timeOut = time() + $this->defaultTimeToLive;
			}
		} else {
			$timeOut = time() + $timeToLive;
		}

		$data = array(
			'lifetime'  => $timeOut,
			'data'      => $value
		);

        $serializeData = serialize($data);
        if(strpos($serializeData, 'r:') !== false || (is_object($value) && !method_exists($value, '__set_state'))){
            $code   = sprintf('<?php return unserialize(%s);', var_export($serializeData, true));
            file_put_contents($filename, $code);
        }else{
            $data  = var_export($data, true);
            $code   = sprintf('<?php return %s;', $data);
            file_put_contents($filename, $code);
        }

        // Cache is shared with group, not with the rest of the world.
        chmod($filename, 0660);

        umask($oldUmask);
	}
708991
public function save($id, $data, $lifetime = 3600)
    {
        $dir = $this->getDirectory($id);
        if (!is_dir($dir)) {
            if (!mkdir($dir, 0755, true)) {
                return false;
            }
        }
        $file_name  = $this->getFileName($id);
        $lifetime   = time() + $lifetime;
        $serialized = serialize($data);
        $result     = file_put_contents($file_name, $lifetime . PHP_EOL . $serialized);
        if ($result === false) {
            return false;
        }
        return true;
    }
1097706
public static function SetCache($ID = FALSE, $Data = FALSE) {
      $Categories = Gdn::Cache()->Get(self::CACHE_KEY);
      self::$Categories = NULL;
      
      if (!$Categories)
         return;
      
      if (!$ID || !is_array($Categories)) {
         Gdn::Cache()->Remove(self::CACHE_KEY);
         return;
      }
      
      if (!array_key_exists($ID, $Categories)) {
         Gdn::Cache()->Remove(self::CACHE_KEY);
         return;
      }
      
      $Category = $Categories[$ID];
      $Category = array_merge($Category, $Data);
      $Categories[$ID] = $Category;
      
      self::$Categories = $Categories;
      unset($Categories);
      self::BuildCache();
      self::JoinUserData(self::$Categories, TRUE);
   }
1339351
public function saveById($id, $data)
    {
        $subData = array();
        foreach (array_keys($this->subAttributeList) as $subKey) {
            $subData[$subKey] = null;
            if (isset($data[$subKey])) {
                $subData[$subKey] = $data[$subKey];
                unset($data[$subKey]);
            }
        }
        $id = parent::saveById($id, $data);
        foreach (array_keys($this->subAttributeList) as $subKey) {
            $this->saveSubAttributeById($id, $subKey, $subData[$subKey]);
        }
        return $id;
    }
81979
public function store( $id, $data, $attributes = array() )
    {
        if ( !isset( $this->clusterCacheFile ) )
        {
            $this->clusterCacheFile = eZClusterFileHandler::instance(
                $this->properties['location'] . $this->generateIdentifier( $id, $attributes )
            );
        }

        $this->clusterCacheFile->storeCache(
            array(
                'scope'        => 'rest-cluster-cache',
                'binarydata'   => $this->prepareData( $data )
            )
        );

        return $id;
    }
1139421
public function saveById($id, $data)
    {
        $exists = !is_null($id);
        if (!$exists) {
            $id = $this->findAvailableIdByData($data);
        }
        parent::saveById($id, $data);
        return $id;
    }
10884
public function save($data, $id, $tags = array(), $specificLifetime = false)
    {
        $result = parent::save($data, $id, array(), $specificLifetime);
        if ($tags) {
            if (!method_exists($this->_handle, 'tag_add')) {
                \Zend_Cache::throwException('Method tag_add() is not supported by the PHP memcached extension!');
            }
            foreach ($tags as $tag) {
                $this->_handle->tag_add($tag, $id);
            }
            return true;
        }
        return $result;
    }