Jamm\Memory\Shm\ShmMem::set_ID PHP Метод

set_ID() публичный Метод

public set_ID ( $ID )
    public function set_ID($ID)
    {
        if (!empty($ID)) {
            $this->id = $ID;
        }
        if (is_string($this->id)) {
            $this->shmkey = ftok($this->id, 'N');
        } else {
            $this->shmkey = $this->id;
        }
        $this->shm = @shmop_open($this->shmkey, "w", 0, 0);
        if (!$this->shm) {
            $this->shm = @shmop_open($this->shmkey, "a", 0, 0);
            if ($this->shm !== false) {
                $this->sem = new ReadOnlyAccess($this->id);
            }
        }
        //if memory not yet exists - lets create
        if (!$this->shm) {
            $this->shm = shmop_open($this->shmkey, "n", 0777, $this->shmsize);
        }
        if (!$this->shm) {
            return false;
        }
        if (empty($this->sem)) {
            $this->sem = new MultiAccess($this->id);
        }
        return true;
    }