Skip to content

Commit 9442632

Browse files
committed
Fixed #866 // Deprecated Method Cassandra\ExecutionOptions starting of Cassandra 1.3 (V8)
1 parent 894421d commit 9442632

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

lib/Phpfastcache/Drivers/Cassandra/Config.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ class Config extends ConfigurationOption
4949
*/
5050
protected $sslVerify = false;
5151

52+
/**
53+
* @var bool
54+
*/
55+
protected $useLegacyExecutionOptions = false;
56+
5257
/**
5358
* @return string
5459
*/
@@ -174,4 +179,22 @@ public function setSslVerify(bool $sslVerify): self
174179
$this->sslVerify = $sslVerify;
175180
return $this;
176181
}
177-
}
182+
183+
/**
184+
* @return bool
185+
*/
186+
public function isUseLegacyExecutionOptions(): bool
187+
{
188+
return $this->useLegacyExecutionOptions;
189+
}
190+
191+
/**
192+
* @param bool $useLegacyExecutionOptions
193+
* @return $this
194+
*/
195+
public function setUseLegacyExecutionOptions(bool $useLegacyExecutionOptions): self
196+
{
197+
$this->useLegacyExecutionOptions = $useLegacyExecutionOptions;
198+
return $this;
199+
}
200+
}

lib/Phpfastcache/Drivers/Cassandra/Driver.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ protected function driverConnect(): bool
167167
protected function driverRead(CacheItemInterface $item)
168168
{
169169
try {
170-
$options = new Cassandra\ExecutionOptions(
170+
$options = $this->getCompatibleExecutionOptionsArgument(
171171
[
172172
'arguments' => ['cache_id' => $item->getKey()],
173173
'page_size' => 1,
@@ -203,7 +203,7 @@ protected function driverWrite(CacheItemInterface $item): bool
203203
if ($item instanceof Item) {
204204
try {
205205
$cacheData = $this->encode($this->driverPreWrap($item));
206-
$options = new Cassandra\ExecutionOptions(
206+
$options = $this->getCompatibleExecutionOptionsArgument(
207207
[
208208
'arguments' => [
209209
'cache_uuid' => new Cassandra\Uuid(),
@@ -267,7 +267,7 @@ protected function driverDelete(CacheItemInterface $item): bool
267267
*/
268268
if ($item instanceof Item) {
269269
try {
270-
$options = new Cassandra\ExecutionOptions(
270+
$options = $this->getCompatibleExecutionOptionsArgument(
271271
[
272272
'arguments' => [
273273
'cache_id' => $item->getKey(),
@@ -320,4 +320,17 @@ protected function driverClear(): bool
320320
return false;
321321
}
322322
}
323+
324+
/**
325+
* @param array<string, mixed> $options
326+
* @return array<string, mixed>|Cassandra\ExecutionOptions
327+
*/
328+
protected function getCompatibleExecutionOptionsArgument(array $options): mixed
329+
{
330+
if ($this->getConfig()->isUseLegacyExecutionOptions()) {
331+
return new Cassandra\ExecutionOptions($options);
332+
}
333+
334+
return $options;
335+
}
323336
}

0 commit comments

Comments
 (0)