Jamm\Memory\Shm\SingleMemory::add PHP Method

add() public method

Excludes simultaneously adding keys to exclude race condition.
public add ( string $key, mixed $value, integer $ttl = 2592000, string | array $tags = NULL ) : boolean | integer
$key string
$value mixed
$ttl integer
$tags string | array
return boolean | integer
    public function add($key, $value, $ttl = 2592000, $tags = NULL)
    {
        if (empty($key)) {
            return false;
        }
        $auto_unlocker = NULL;
        if (!$this->sem->get_access_write($auto_unlocker)) {
            return false;
        }
        $key = (string) $key;
        $this->readmemory();
        if (isset($this->mem[self::map_keys][$key])) {
            return false;
        }
        return $this->save($key, $value, $ttl, $tags);
    }