@param     $key
@param     $value
@param int $ttl

@return $this
185057
protected function insertToDatabase($key, $value, $ttl = 0)
    {
        $value = $this->storageDataStructure($value);

        $calculatedTtl = $this->fromDefaultTtl($ttl);
        $calculatedTtl = new DateTime(\date('Y-m-d H:i:s', $this->getCalculatedTtl($calculatedTtl)));

        $databaseValue = $this->getFromDatabase($key);
        if (false === empty($databaseValue)) {
            $databaseValue[self::CACHE_VALUE] = $value;
            $this->updateToDatabase($key, $databaseValue, $calculatedTtl);
            return $this;
        }

        $stmt = $this->connection->prepare(
            \sprintf(
                'INSERT INTO %s(id,%s,%s,%s) VALUES(%s,%s,%s,%s)',
                $this->cacheTableName,
                self::TABLE_CACHE_ID,
                self::TABLE_CACHE_VALUE,
                self::TABLE_CACHE_TTL,
                self::SPHINX_ID_PLACEHOLDER,
                self::QUERY_ID_PLACEHOLDER,
                self::QUERY_VALUE_PLACEHOLDER,
                self::QUERY_TTL_PLACEHOLDER
            )
        );

        $sphinxId = (int) $this->connection->lastInsertId()+1;

        $stmt->bindParam(self::SPHINX_ID_PLACEHOLDER, $sphinxId, PDO::PARAM_STR);
        $stmt->bindParam(self::QUERY_ID_PLACEHOLDER, $key, PDO::PARAM_STR);
        $stmt->bindParam(self::QUERY_VALUE_PLACEHOLDER, $value, PDO::PARAM_STR);
        $calculatedTtl = $calculatedTtl->format('Y-m-d H:i:s');
        $stmt->bindParam(self::QUERY_TTL_PLACEHOLDER, $calculatedTtl, PDO::PARAM_STR);
        $stmt->execute();

        return $this;
    }
682415
public function set($key, $value, $ttl = 0)
    {
        $ttl = $this->fromDefaultTtl($ttl);

        if ($ttl >= 0) {
            $calculatedTtl = $this->getCalculatedTtl($ttl);
            $data          = $this->buildDataCache($value, $calculatedTtl);
            \file_put_contents($this->getFilenameFromCacheKey($key), $data);
            $this->setChain($key, $value, $ttl);
        }

        return $this;
    }
652637
protected function setToCache($cacheKey, $value, $ttl = null)
    {
        // Seralize as JSON to ensure array etc can be stored
        $value = Convert::raw2json($value);

        return $this->getCache()->set($cacheKey, $value, $ttl);
    }
190065
public function saveItem($key, $value, $ttl = null)
    {
        $cache = [
            'start' => time(),
            'ttl'   => ($ttl !== null) ? (int) $ttl : $this->ttl,
            'value' => $value,
        ];

        apcu_store($key, $cache, $cache['ttl']);

        return $this;
    }
738208
private function add($key, $value, $ttl = 2592000)
    {
        $res = self::$memcached->add(CFG_DOMAIN . $key, $value, $ttl);
        return $res;
    }
387274
public function put($key, $value, $ttl = null)
    {
        if ($ttl === null) {
            return $this->forever($key, $value);
        }

        $this->pushStandardKeys($this->tags->getNamespace(), $key);

        return parent::put($key, $value, $ttl);
    }
1268037
public function set($key, $value, $ttl)
    {
        if (!$this->safe) {
            return false;
        }

        return apc_store($key, $value, $ttl);
    }
434056
public function update($key, $value, $ttl = 0, $condition = array())
    {
        $extra = array('prevExist' => 'true');

        if ($condition) {
            $extra = array_merge($extra, $condition);
        }
        $body = $this->set($key, $value, $ttl, $extra);
        if (isset($body['errorCode'])) {
            throw new KeyNotFoundException($body['message'], $body['errorCode']);
        }
        return $body;
    }
1141041
public function set($key, $value, $ttl = null)
    {
        try {
            $this->_set($key, $value, $ttl);
        } catch (RootException $e) {
            if ($e instanceof ContainerExceptionInterface) {
                throw $e;
            }

            throw $this->_createContainerException($this->__('Could not set data'), null, $e, $this);
        }
    }
1105002
public function set($key, $value, $ttl)
    {
        if ($value === false) {
            throw new InvalidValueException(['`:key` key cache value can not `false` bool value', 'key' => $key]);
        } elseif (is_scalar($value) || $value === null) {
            if (is_string($value) && $value !== '' && $value[0] !== '{' && $value[0] !== '[') {
                $data = $value;
            } else {
                $data = json_encode(['_wrapper_' => $value], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
            }
        } elseif (is_array($value) && isset($value['_wrapper_'])) {
            $data = json_encode(['_wrapper_' => $value], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
        } else {
            $data = json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
        }

        if ($data === false) {
            throw new InvalidValueException([
                '`:key` key cache value json_encode failed: `:code` `:message`',
                'key' => $key,
                'code' => json_last_error(),
                'message' => json_last_error_msg()
            ]);
        }

        $this->do_set($key, $data, $ttl);
    }
592877
public function set($key, $value, $ttl = null)
	{
	    if (!$this->connect()) {
	        return null;
	    }
	    //\Wslim\Ioc::logger('cache')->debug(sprintf('set: %s %s', $key, print_r($value, true)));
	    
		$oldKey = $key;
		
		$key = $this->formatKey($key);
		$value = $this->encodeValue($value);		
		$ttl = $ttl ? $ttl : $this->options['ttl'];

		$result = $this->driver->set($key, $value, MEMCACHE_COMPRESSED, $ttl);
		
		return $result;
	}
978821
public function saveItem($key, $value, $ttl = null)
    {
        $cache = [
            'start' => time(),
            'ttl'   => ($ttl !== null) ? (int) $ttl : $this->ttl,
            'value' => $value,
        ];
        if ($cache['ttl'] != 0) {
            $this->redis->set($key, json_encode($cache), $cache['ttl']);
        } else {
            $this->redis->set($key, json_encode($cache));
        }

        return $this;
    }
906591
public function set($key, $value, $ttl = 2592000)
    {
        if (!self::$instance) {
            self::getInstance();
        }

        return self::$redis->set(CFG_DOMAIN . $key, $value, $ttl);
    }
401158
public function setEntry($Key, $Value, $TTL = 3600)
    {
        $Value = $this->serializeEntry($Value);
        if ($this->Using === 'APCu') {
            if (apcu_store($Key, $Value, $TTL)) {
                return $this->Modified = true;
            }
            return false;
        }
        if ($this->Using === 'Memcached') {
            if ($TTL >= 2592000) {
                $TTL += time();
            }
            if ($this->WorkingData->set($Key, $Value, $TTL)) {
                return $this->Modified = true;
            }
            return false;
        }
        if ($this->Using === 'Redis') {
            if ($this->WorkingData->set($Key, $Value, $TTL)) {
                return $this->Modified = true;
            }
            return false;
        }
        if ($this->Using === 'PDO') {
            if ($TTL > 0) {
                $TTL += time();
            }
            $PDO = $this->WorkingData->prepare(self::setQuery);
            if ($PDO !== false && $PDO->execute([
                'key' => $Key,
                'data' => $Value,
                'time' => $TTL,
                'key2' => $Key,
                'data2' => $Value,
                'time2' => $TTL
            ])) {
                return ($PDO->rowCount() > 0 && $this->Modified = true);
            }
            return false;
        }
        if (is_array($this->WorkingData)) {
            if ($TTL > 0) {
                $TTL += time();
                $this->WorkingData[$Key] = ['Data' => $Value, 'Time' => $TTL];
            } else {
                $this->WorkingData[$Key] = $Value;
            }
            return $this->Modified = true;
        }
        return false;
    }
745583
public function add($key, $value, $ttl = null)
    {
        if ($ttl !== null) {
            if ($this->getSeconds($ttl) <= 0) {
                return false;
            }

            // If the store has an "add" method we will call the method on the store so it
            // has a chance to override this logic. Some drivers better support the way
            // this operation should work with a total "atomic" implementation of it.
            if (method_exists($this->store, 'add')) {
                $seconds = $this->getSeconds($ttl);

                return $this->store->add(
                    $this->itemKey($key), $value, $seconds
                );
            }
        }

        // If the value did not exist in the cache, we will put the value in the cache
        // so it exists for subsequent requests. Then, we will return true so it is
        // easy to know if the value gets added. Otherwise, we will return false.
        if (is_null($this->get($key))) {
            return $this->put($key, $value, $ttl);
        }

        return false;
    }
906339
public function create($key, $value, $ttl = 0)
    {
        return $request = $this->set($key, $value, $ttl, ['prevExist' => 'false']);
    }
814053
public function set($key, $value, $ttl = 0)
    {
        $this->cache[$key] = new Item($value);
        return true;
    }