Set IronCache as session store handler

@param null|integer $session_expire_time Expire time in seconds
504384
public function set_as_session_store($session_expire_time = null)
    {
        if ($session_expire_time != null) {
            $this->session_expire_time = $session_expire_time;
        }
        session_set_save_handler(
            array($this, 'session_open'),
            array($this, 'session_close'),
            array($this, 'session_read'),
            array($this, 'session_write'),
            array($this, 'session_destroy'),
            array($this, 'session_gc')
        );
    }
466428
def _update_session_expiration(self):
        

        session_time = oz.settings["session_time"]

        if session_time:
            self.redis().expire(self._session_key, session_time)
102144
public function updateExpire(string $key, int $expire): bool
    {
        if (!$this->ifExists($key)) {
            throw new Exception(
                'The key '.$key.' not exist on memcache(d) server',
                self::ERR_KEY_NOT_EXIST
            );
        }
        
        return $this->touch($key, $expire);
    }
1168384
private function storeValueInCache($key, $value, $expiration = null)
    {
        $this->cache[$key] = new MemcacheObject($key, serialize($value), $this->normalizeExpirationTime($expiration));
    }
1281144
protected function store_redis_cache_write(
		$token, $data, $expire_at, $expire=null
	) {
		if (!$this->redis)
			return;

		$key = sprintf('%s:%s', $this->token_name, $token);
		$this->redis->set($key, json_encode($data));

		if ($expire === null) {
			$expire_at = str_replace(' ', 'T', $expire_at) . 'Z';
			$expire_at = \DateTime::createFromFormat(
				\DateTime::ATOM, $expire_at)->format("U");
			$expire = $expire_at;
		}
		$this->redis->expire($key, $expire);

		$this->logger->debug(sprintf(
			"Zapmin: session written to cache: '%s' <- '%s'.",
			$token, json_encode($data)));
	}
761904
public static function set(string $key, $value = null, int $expiration = 0): ?Cache
    {
        if (!self::$instance) {
            return null;
        }

        self::$instance->engine->set($key, $value, $expiration);

        return self::$instance;
    }
774218
public static function SendExpires( $expireStamp = null )
   {

      if ( \is_null( $expireStamp ) || empty( $expireStamp ) )
      {
         $expireStamp = \time();
      }

      if ( \is_int( $expireStamp ) )
      {
         \header( 'Expires: ' . \date( 'D, d M Y H:i:s O', $expireStamp ) );
      }
      else if ( $expireStamp instanceof \DateTimeInterface )
      {
         \header( 'Expires: ' . $expireStamp->format( 'D, d M Y H:i:s O' ) );
      }
      else if ( TypeTool::IsInteger( $expireStamp ) )
      {
         \header( 'Expires: ' . \date( 'D, d M Y H:i:s O', \intval( $expireStamp ) ) );
      }
      else if ( TypeTool::IsStringConvertible( $expireStamp, $str ) )
      {
         $stamp = \strtotime( $str );
         if ( $stamp > 0 )
         {
            \header( 'Expires: ' . \date( 'D, d M Y H:i:s O', $stamp ) );
         }
      }

   }
926472
public static function init()
	{
		if(!self::$isInited)
		{
			self::name(Config::get('@.SESSION_NAME', null));
			self::savePath(Config::get('@.SESSION_SAVEPATH', null));
			self::useCookies(Config::get('@.SESSION_USE_COOKIES', null));
			self::cacheExpire(Config::get('@.SESSION_CACHE_EXPIRE', null));
			self::cacheLimiter(Config::get('@.SESSION_CACHE_LIMITER', null));
			self::gcProbability(Config::get('@.SESSION_GC_PROBABILITY', null));
			self::maxLifetime(Config::get('@.SESSION_MAX_LIFETIME', null));
			self::prefix(Config::get('@.SESSION_PREFIX', ''));
			self::cookieDomain(Config::get('@.SESSION_COOKIE_DOMAIN',null));
			$saveHandler = Config::get('@.SESSION_SAVE_HANDLER', 'files');
			self::saveHandler($saveHandler);
			if('user' === $saveHandler)
			{
				self::userSaveHandler(Config::get('@.SESSION_USER_SAVE_HANDLER'));
			}
			self::$isInited = true;
			if(null !== self::$sessionID)
			{
				session_id(self::$sessionID);
			}
			session_start();
			session_write_close();
			return true;
		}
		else
		{
			return false;
		}
	}
404811
public function cacheObject($key, $object, $timeoutSeconds = -1) {

        $cache = HttpSession::instance()->getValue("__SESSION_CACHED_ITEMS");
        if (!is_array($cache)) {
            $cache = array();
        }

        $cache[$key] = $object;

        HttpSession::instance()->setValue("__SESSION_CACHED_ITEMS", $cache);


        if ($timeoutSeconds > 0) {
            $timeouts = HttpSession::instance()->getValue("__SESSION_CACHE_TIMEOUTS");
            if (!is_array($timeouts)) {
                $timeouts = array();
            }

            $dateTime = new \DateTime();
            $dateTime->add(new \DateInterval("PT" . $timeoutSeconds . "S"));
            $timeouts[$key] = $dateTime->format("d/m/Y H:i:s");

            HttpSession::instance()->setValue("__SESSION_CACHE_TIMEOUTS", $timeouts);
        }


    }
816381
private function setSessionHandler()
    {
        $vitex = Vitex::getInstance();
        $driver = $vitex->getConfig('session.driver');
        switch ($driver){
            case 'cache':
                session_set_save_handler(new CacheHandler(),true);
                break;
            case 'file':
                session_set_save_handler(new FileHandler(),true);
                break;
        }
    }
163337
function set($key, $value, $expire = 0)
    {
        if ($this->memcached)
        {
            return $this->cache->set($key, $value, $expire);
        }
        else
        {
            return $this->cache->set($key, $value, $this->flags, $expire);
        }
    }
795259
public function write($sessionId, $data)
    {
        $t = microtime(true);
        $expiration = $this->_lifeTime + time();
 
        //we store time of the db record expiration in the Memcache
        if ($this->_initSessionData !== $data) {
            Kwf_Registry::get('db')->query("REPLACE INTO kwf_sessions (sessionId, expiration, data) VALUES(?, ?, ?)", array($sessionId, $expiration, $data));
            $this->_memcacheSet($sessionId, $data);
        }
        Kwf_Benchmark::count('sessionhdl', 'read: '.((microtime(true)-$t)*1000).'ms');
        return true;
    }
1298505
function set($key, $data, $expire = 0)
    {
        return $this->connection->set($key, $data, MEMCACHE_COMPRESSED, $expire);
    }
1215778
public static function set(string $key, $value, int $expire = null): bool
    {
        return self::storage()->set($key, $value, $expire);
    }
1133227
public function noCache()
    {
        $header = new Expires('Mon, 26 Jul 1997 05:00:00 GMT');
        $this->addHeader($header);

        $header = new CacheControl('no-cache');
        $this->addHeader($header);

        $header = new Pragma('no-cache');
        $this->addHeader($header);
    }
496559
public function set($name, $value, $expire = null) {
        if (is_null($expire)) {
            $expire = $this->options['expire'];
        }
        //if ($this->tag && !$this->has($name)) {
        //    $first = true;
        //}
        //$key = $this->getCacheKey($name);
        $expire = 0 == $expire ? 0 : $_SERVER['REQUEST_TIME'] + $expire;
        if ($this->handler->set($name, $value, $expire)) {
            //isset($first) && $this->setTagItem($name);
            return true;
        }
        return false;
    }
1292060
public static function cache($expire = 3600, $last_modify = null) {
        $time    = time();
        $date    = gmdate('D, d M Y H:i:s', $time) . ' GMT';
        $headers = [
            'Age'           => $expire,
            'Date'          => $date,
            'Expires'       => gmdate('D, d M Y H:i:s', $time + $expire) . ' GMT',
            'Cache-Control' => 'public, must-revalidate, max-age=' . $expire,
            'Pragma'        => 'cache'
        ];
        if ($last_modify) {
            $ldate                    = @gmdate('D, d M Y H:i:s', $last_modify) . ' GMT';
            $headers['Last-Modified'] = $ldate;
        }
        foreach ($headers as $header => $val) {
            @header($header . ': ' . $val);
        }
    }