Serializes the data with lifetime information

@param mixed $data The data to serialize
@param int $lifetime The lifetime in seconds
@return string The serialized data
488625
protected function serialize($data, int $lifetime) : string
    {
        return json_encode(
            ['d' => serialize($data), 't' => time() + $lifetime]
        );
    }
603023
public function encode($data)
    {
        $data['exp'] = time() + $this->lifeTime;

       return JWT::encode($data, $this->secretKey);
    }
619073
public function serialize($data) {
        $list = $this->recursive($data, 1);
        return $this->renderWith(['Result', 'Controller'], ['Data' => \ArrayList::create($list)]);
    }
985337
protected function serializeItem($data) {
        if ($data instanceof IArrayable) {
            return $data->toArray();
        } else if ($data instanceof IJsonable) {
            return $data->toJson();
        } else if ($data instanceof IStringable) {
            return $data->toString();
        }

        return $data;
    }
685776
public function serialize($data)
    {
        $json = '';
        $formattedData = null;

        if ($data instanceof DataObject) {
            $formattedData = $this->formatDataObject($data);
        } elseif ($data instanceof DataList) {
            $formattedData = $this->formatDataList($data);
        }

        if ($formattedData !== null) {
            $json = $this->jsonify($formattedData);
        } else {
            //fallback: convert non array to object then encode
            if (!is_array($data)) {
                $data = (object) $data;
            }
            $json = $this->jsonify($data);
        }

        return $json;
    }
1119316
public static function set($key, $data, $lifetime = NULL, $group = NULL)
	{
		$result = FALSE;
		try {
			!self::classExists() or $result = self::instance($group)->set($key, $data, $lifetime);
		} catch (Cache_Exception $e) {
			self::exception($e);
		}

		return $result;
	}
269680
public function get(int $lifetime = null, bool $returnObj = false)
    {
        $lifetime = $lifetime ?? 300;
        $key = $this->checksum();

        // try to get image from cache
        $cachedImageData = $this->cache->get($key);

        // if imagedata exists in cache
        if ($cachedImageData) {
            // transform into image-object
            if ($returnObj) {
                $image = $this->manager->make($cachedImageData);
                $cachedImage = new CachedImage;

                return $cachedImage->setFromOriginal($image, $key);
            }

            // return raw data
            return $cachedImageData;
        }

        // process image data
        $image = $this->process();

        // encode image data only if image is not encoded yet
        $encoded = $image->encoded ?: (string) $image->encode();

        // save to cache...
        $this->cache->set($key, $encoded, $lifetime);

        // return processed image
        return $returnObj ? $image : $encoded;
    }
1193425
public static function create(string $name, int $lifetime = 300): string
    {
        $token = sha1(microtime());
        $tokenData = [
            'token' => $token,
            'time' => time(),
            'lifetime' => $lifetime
        ];
        Session::set($name, $tokenData, self::$namespace);
        return $token;
    }
144025
public function unredislize($data)
    {
        $data = urldecode($data);

        if (self::isSerialized($data)) {
            $unserializedData = @unserialize($data);
            if ($unserializedData !== false) {
                return $unserializedData;
            }
        }

        return $data;
    }
1114525
public function writeData($data)
	{
		if (strlen($data) - 4 > $this->_limit) {
			$data = $this->_addContinue($data);
		}
		$this->_datasize += strlen($data);

		return $data;
	}
1127443
protected function pack($data, int $seconds = 0): string
    {
        return serialize(
            array(
                'data' => $this->toPack($data),
                'timeout' => $seconds ? $this->microtime($seconds * 1000) : 0,
            )
        );
    }
768567
public function save($id, $data, $lifetime = null)
    {
        if ($this->enabled) {
            if ($lifetime === null) {
                $lifetime = $this->getLifetime();
            }
            $this->driver->save($id, $data, $lifetime);
        }
    }
821160
public function serialize($data, $group = null)
    {
        $context = new SerializationContext();

        if ($group) {
            $context->setGroups($group);
        }

        return $this->serializer->serialize($data, 'json', $context);
    }
830840
public static function jsonEncode($data)
    {
        $json = json_encode($data);
        // if json_encode failed
        if ($json === false) {
            self::jsonLastError();
        }
        return $json;
    }
322061
protected function writeCache($key, &$data, $lifetime)
    {
        $this->cacheManager->set($key, $data, [], $lifetime);
    }
1335220
public function write($data)
    {
        if (!$this->connected) {
            if (!$this->connect()) {
                return false;
            }
        }
        return fwrite($this->connection, $data, strlen($data));
    }
31069
public function serialize($data) {
        $xml = new \SimpleXMLElement('<result/>');
        $this->toXml($xml, $data);
        return $xml->asXML();
    }