public function add(string $key, $value, int $ttl = null)
    {
        // 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(static::$handler, 'add')) {
            return static::$handler->add(
                $this->normalized($key),
                $value,
                $ttl ?? $this->ttl
            );
        }

        // 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->set($key, $value, $ttl ?? $this->ttl);
        }

        return false;
    }
public function add(string $key, $value, int $ttl = null)
    {
        // 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(static::$handler, 'add')) {
            return static::$handler->add(
                $this->normalized($key),
                $value,
                $ttl ?? $this->ttl
            );
        }

        // 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->set($key, $value, $ttl ?? $this->ttl);
        }

        return false;
    }
public function add ( string $ key , $ value , int $ ttl = null ) { // 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 ( static :: $ handler , 'add' ) ) { return static :: $ handler -> add ( $ this -> normalized ( $ key ) , $ value , $ ttl ?? $ this -> ttl ) ; } // 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 -> set ( $ key , $ value , $ ttl ?? $ this -> ttl ) ; } return false ; }
Store an item in the cache if the key does not exist.

@param string                               $key   键
@param mixed                                $value 值
@param \DateTimeInterface|\DateInterval|int $ttl   生命值，秒

@return bool
Store an item in the cache if the key does not exist .