Jamm\Memory\Shm\SHMObject::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 key
$value mixed value
$ttl integer Time To Live in seconds (value will be added to the current time)
$tags array | string tag array of tags for this key
return boolean
    public function add($key, $value, $ttl = 259200, $tags = NULL)
    {
        if (empty($key) || $value == NULL) {
            $this->ReportError('empty keys and values are not allowed', __LINE__);
            return false;
        }
        $key = (string) $key;
        $auto_unlocker = NULL;
        if (!$this->mutex->get_access_write($auto_unlocker)) {
            return false;
        }
        $map = $this->mem_object->read('map');
        if (isset($map[$key])) {
            return false;
        }
        return $this->save($key, $value, $ttl, $tags);
    }