Jamm\Memory\CouchbaseObject::add PHP Method

add() public method

Add value to memory storage, only if this key does not exists (or false will be returned).
public add ( string $key, mixed $value, integer $ttl = 259200, array | string $tags = NULL ) : boolean
$key string
$value mixed
$ttl integer
$tags array | string
return boolean
    public function add($key, $value, $ttl = 259200, $tags = NULL)
    {
        $ttl = $this->ttl_to_expiration($ttl);
        try {
            $result = $this->Couchbase->add($this->prefix . $key, $value, $ttl);
        } catch (\Exception $Exception) {
            return false;
        }
        if (!$result) {
            return false;
        }
        $this->setKeyTTL($key, $ttl);
        if (!empty($tags)) {
            $this->setTags($key, $tags);
        }
        return true;
    }