protected function addValue($key, $value, $expire)
    {
        $this->gc();

        if ($expire > 0) {
            $expire += time();
        } else {
            $expire = 0;
        }

        try {
            $this->db->getCollection($this->cacheCollection)
                ->insert([
                    'id' => $key,
                    'expire' => $expire,
                    'data' => $value,
                ]);

            return true;
        } catch (\Exception $e) {
            return false;
        }
    }
protected function addValue($key, $value, $expire)
    {
        $this->gc();

        if ($expire > 0) {
            $expire += time();
        } else {
            $expire = 0;
        }

        try {
            $this->db->getCollection($this->cacheCollection)
                ->insert([
                    'id' => $key,
                    'expire' => $expire,
                    'data' => $value,
                ]);

            return true;
        } catch (\Exception $e) {
            return false;
        }
    }
protected function addValue ( $ key , $ value , $ expire ) { $ this -> gc ( ) ; if ( $ expire > 0 ) { $ expire += time ( ) ; } else { $ expire = 0 ; } try { $ this -> db -> getCollection ( $ this -> cacheCollection ) -> insert ( [ 'id' => $ key , 'expire' => $ expire , 'data' => $ value , ] ) ; return true ; } catch ( \ Exception $ e ) { return false ; } }
Stores a value identified by a key into cache if the cache does not contain this key.
This method should be implemented by child classes to store the data
in specific cache storage.
@param string $key the key identifying the value to be cached
@param string $value the value to be cached
@param int $expire the number of seconds in which the cached value will expire. 0 means never expire.
@return bool true if the value is successfully stored into cache, false otherwise
Stores a value identified by a key into cache if the cache does not contain this key . This method should be implemented by child classes to store the data in specific cache storage .