Sets a cache entry by key

@param string $key
@param mixed $value
@param int $expiration

@return bool
433114
public function set($key, $value = null, $expiration = 0)
    {
        if (empty($key)) return false;

        if (isset($this->list[$key])) {
            if (!$this->list[$key] == $value) return true;

            $this->list[$key]               = $value;
            $this->cacheListing[$key]->data = $value;
            $this->cacheListing[$key]->save();

            return true;
        }

        $this->list[$key] = $value;
        $entry            = new Entry();

        $entry->setKeyName($key);
        $entry->setKey($this->getRandomInt());

        $entry->setPermission(MemoryHandler::DEFAULT_PERMISSIONS);
        $entry->setMode(MemoryHandler::CREATE_MOD);
        $entry->setSize((int)MemoryHandler::DEFAULT_SIZE);
        $entry->setOffset((int)MemoryHandler::DEFAULT_OFFSET);
        $entry->setStart((int)0);
        $entry->setCount((int)0);
        $entry->setTtl((int)$expiration);
        $entry->setData($value);

        $entry->save();
        $this->cacheListing[$key] = $entry;

        return true;
    }
948614
public function setHex(string $value, int $expire = 0): bool
    {
        return $this->setRaw(pack('H*', $value), $expire);
    }
572463
public function increment($key, $value = 1, $expiration = 0)
    {
        $new = intval($this->get($key));
        $new += $value;
        $this->set($key, $new, $expiration);
    }
156883
public function store($key, $value = null, int $expiration = 0): bool
    {
        return $this->set($key, $value, $expiration);
    }
327652
protected function setCacheContent($key = null, $value = null, $expire = 0, array $tags = [])
    {
        if ($this->cache instanceof CacheInterface && isset($key)) {
            if (!empty($this->cachePlaceholders)) {
                $result = $value;
                $value = [];
                $value['result'] = $result;
                $value['placeholders'] = $this->cachePlaceholders;
            }
            $this->cache->set(
                $key,
                $value,
                $expire,
                is_string($tags) ? explode(',', $tags) : $tags
            );
            $this->cachePlaceholders = [];
        }
    }
413901
function set($key, $value, $expire = 0)
    {
        if ($expire <= 0)
        {
            $expire = 0x7fffffff;
        }
        return $this->redis->setex($key, $expire, serialize($value));
    }
1330307
public function store($key, $data, $expiration = 0) {
    $storeData = array(
      'time'   => time(),
      'expire' => $expiration,
      'data'   => serialize($data)
    );
    $dataArray = $this->_loadCache();
    if (true === is_array($dataArray)) {
      $dataArray[$key] = $storeData;
    } else {
      $dataArray = array($key => $storeData);
    }
    $cacheData = json_encode($dataArray);
    file_put_contents($this->getCacheDir(), $cacheData);
    return $this;
  }
375897
public function memcacheSet($key, $value, $expiration = null)
    {
        if ($this->isSingle()) {
            MemcacheKit::set($key, $value, $expiration);
        }
    }
224755
public function update($key, $value, $expire = 0)
    {
        $arr = $this->get($key);
        if (!empty($arr)) {
            $arr = array_merge($arr, $value);
            return $this->set($key, $arr, $expire);
        }
        return 0;
    }
1092184
public static function set($key, $value) {
		$memcache = self::connect();
		$config = \Skeleton\Object\Config::$cache_handler_config;
		$memcache->add($key, $value, false, $config['expire']);
	}
1267851
public function set($name, $value, $expire) {
        if (is_null($expire)) {
            $expire = $this->options['expire'];
        }
        $filename = $this->setCacheKey($name);

        $data = serialize($value);
        $data = "<?php\n//" . sprintf('%012d', $expire) . $data . "\n?>";
        file_put_contents($filename, $data);
    }
911813
public function put($key, $value, $expire = null)
    {
        return call_user_func_array("set{$this->getPrefix()}_transient", [
            $key,
            $value,
            $expire ?: $this->getDefault('expire'),
        ]);
    }
85942
protected function setItem(string $key, string $value, int $expiration)
    {
        if ($this->memcache instanceof \Memcached) {
            return $this->memcache->set($key, $value, $expiration);
        }
        return $this->memcache->set($key, $value, $this->flags, $expiration);
    }
918626
public function set(string $key, $value = null, int $expiration = 0) : bool
    {
        if (apcu_store($key, $value, $expiration)) {
            $this->updateMetaData($key, $expiration);
            $this->saveCacheListing();

            return true;
        }

        return false;
    }
1088702
public function set($key, $value, $expire = NULL) {
    $key = $this->createkey($key);
    if (!$this->lockBackend->acquire($key)) {
      $this->lockBackend->wait($key);
      if (!$this->lockBackend->acquire($key)) {
        throw new TempStoreException("Couldn't acquire lock to update item '$key' in '{$this->storage->getCollectionName()}' temporary storage.");
      }
    }

    $value = (object) [
      'owner' => $this->getOwner(),
      'data' => $value,
      'updated' => (int) $this->requestStack->getMasterRequest()->server->get('REQUEST_TIME'),
    ];

    // Fallback to the default expire.
    if (empty($expire)) {
      $expire = $this->expire;
    }

    $this->storage->setWithExpire($key, $value, $expire);
    $this->lockBackend->release($key);
  }
191998
public function write($key, $value, $expire = null) 
    {
        if (!$this->enabled) {
            return ;
        }

        if ($expire === null) {
            $expire = $this->expire;
        }
        
        $data = [
            'time'   => time(),
            'expire' => time() + $expire,
            'value'  => $value,
        ];
    
        $this->stats['execTimes'] ++;
        $this->stats['writeTimes'] ++;            
        $this->stats['writeSize'] += strlen(var_export($value, true))/1024;
        $this->temp[$key] = $data;
        
        try {
            $this->waitUnlock($key);
            $this->lock($key);
            $this->store($key, $data);
            $this->unlock($key);
        } catch (\wf\cache\Exception $e) {
            $this->unlock($key);
            throw $e;
        }
    }
1300805
public function set(string $key, string $value, int $expire): bool {
		$filename = $this->generateFilename($key);
		$data     = "<?php\n//" . sprintf('%012d', $expire) . sprintf('%012d', time()) . $value . "\n?>";
		return $this->filePutContents($filename, $data);
	}