MatthiasMullie\Scrapbook\Adapters\Apc::replace PHP Method

replace() public method

public replace ( $key, $value, $expire )
    public function replace($key, $value, $expire = 0)
    {
        $ttl = $this->ttl($expire);
        // APC doesn't support replace; I'll use get to check key existence,
        // then safely replace with cas
        $current = $this->get($key, $token);
        if ($current === false) {
            return false;
        }
        // negative TTLs don't always seem to properly treat the key as deleted
        if ($ttl < 0) {
            $this->delete($key);
            return true;
        }
        // no need for locking - cas will do that
        return $this->cas($token, $key, $value, $ttl);
    }