Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for couchbase extention v4.2.1 #3

Merged
merged 13 commits into from
Apr 26, 2024
5 changes: 3 additions & 2 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ jobs:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.0', '8.1', '8.2', '8.3']
name: PHP ${{ matrix.php-versions }} quality/tests on ${{ matrix.operating-system }}
ext-versions: ['couchbase-4.1.6', 'couchbase']
name: PHP ${{ matrix.php-versions }} using ${{ matrix.ext-versions }} quality/tests on ${{ matrix.operating-system }}
env:
extensions: couchbase, pcntl, posix
extensions: ${{ matrix.ext-versions }}, pcntl, posix
key: cache-v1
steps:
- name: Checkout
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 9.2.1
#### 25 April 2024
- __Driver Core__
- `Couchbasev4` Update to support couchbase 4.2.1 and above, which need a notify call when forking the process.

## 9.2.0
##### 10 january 2024
- __Driver Core__
Expand Down
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,27 @@ composer install phpfastcache/couchbasev4-extension
2️⃣ The composer `Couchbase/Couchbase` library 4.x at least

#### ⚠️ This extension optionally requires:
1️⃣ The PHP `Posix` to fix a known Couchbase Extension bug [PCBC-886](https://issues.couchbase.com/projects/PCBC/issues/PCBC-886).
Once this bug has been fixed the dependency suggestion will be removed.
If your application wants to fork the processes using `pcntl_fork()` the `Posix` extension is needed, and you want the fix to be enabled, set up the config like this:
1️⃣ The PHP `Posix` extension is needed use `pcntl_fork()` for process forking.

To fork a php process correctly you will need to tell the Couchbase diver to prepare for the fork.

⚠️ __WARNING__ You **must** call the drivers `Phpfastcache\Drivers\Couchbasev4\Driver::prepareToFork()` just before the `pcntl_fork()` call or the child process will lock up.

#### Example
```php
$config = (new CouchbaseConfig())->setDoForkDetection(true);
try {
\Phpfastcache\Drivers\Couchbasev4\Driver::prepareToFork();
$pid = pcntl_fork();
if ($pid == -1) {
// There was a problem with forking the process
} else if ($pid) {
// continue parent process operations
} else {
// continue child process operations
}
} catch (PhpfastcacheDriverCheckException) {
// the driver did not allow you to fork the process
}
```

2️⃣ Also the PHP `Pcntl` if you plan to contribute to this project and run the tests before pushing your Merge Request.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"require": {
"php": ">=8.0",
"phpfastcache/phpfastcache": "^9.2",
"couchbase/couchbase": "^4.0",
"couchbase/couchbase": "^4.2.1",
"ext-couchbase": "^4.0"
},
"suggest": {
Expand Down
15 changes: 0 additions & 15 deletions lib/Phpfastcache/Extensions/Drivers/Couchbasev4/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class Config extends ConfigurationOption
protected bool $secure = false;
protected bool $allowFlush = true;
protected bool $flushFailSilently = false;
protected bool $doForkDetection = false;

protected ?ClusterOptions $clusterOptions = null;

Expand Down Expand Up @@ -224,18 +223,4 @@ public function getClusterOptions(): ClusterOptions
}
return $this->clusterOptions;
}

public function isDoForkDetection(): bool
{
return $this->doForkDetection;
}

public function setDoForkDetection(bool $doForkDetection): static
{
if ($doForkDetection && !extension_loaded('posix')) {
throw new PhpfastcacheInvalidArgumentException('Posix extension is required to enable the doForkDetection config entry.');
}

return $this->setProperty('doForkDetection', $doForkDetection);
}
}
Loading
Loading