Skip to content

Commit

Permalink
fix: deprecate setIfNotExists and use setIfAbsent in data client (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgautier404 authored May 30, 2024
1 parent 016b5dd commit 65abdd8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/Cache/CacheClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,7 @@ public function setIfNotEqual(string $cacheName, string $key, string $value, str
* Associates the given key with the given value. If a value for the key is
* already present it is not replaced with the new value.
*
* @deprecated Use setIfAbsentAsync instead
* @param string $cacheName Name of the cache to store the key and value in
* @param string $key The key to set.
* @param string $value The value to be stored.
Expand Down Expand Up @@ -784,6 +785,7 @@ public function setIfNotExistsAsync(string $cacheName, string $key, string $valu
* Associates the given key with the given value. If a value for the key is
* already present it is not replaced with the new value.
*
* @deprecated Use setIfAbsent instead
* @param string $cacheName Name of the cache to store the key and value in
* @param string $key The key to set.
* @param string $value The value to be stored.
Expand Down
8 changes: 6 additions & 2 deletions src/Cache/Internal/ScsDataClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,9 @@ function () use ($call): SetIfNotEqualResponse {
}

/**
* SetIfNotExists is deprecated on the service. Here we call the new SetIfAbsent
* and return SetIfNotExists responses.
* @deprecated Use SetIfAbsent instead
* @param string $cacheName
* @param string $key
* @param string $value
Expand All @@ -643,11 +646,12 @@ public function setIfNotExists(string $cacheName, string $key, string $value, $t
validateCacheName($cacheName);
validateNullOrEmpty($key, "Key");
$ttlMillis = $this->ttlToMillis($ttlSeconds);
$setIfNotExistsRequest = new _SetIfNotExistsRequest();
$setIfNotExistsRequest = new _SetIfRequest();
$setIfNotExistsRequest->setAbsent(new Absent());
$setIfNotExistsRequest->setCacheKey($key);
$setIfNotExistsRequest->setCacheBody($value);
$setIfNotExistsRequest->setTtlMilliseconds($ttlMillis);
$call = $this->grpcManager->client->SetIfNotExists(
$call = $this->grpcManager->client->SetIf(
$setIfNotExistsRequest,
["cache" => [$cacheName]],
["timeout" => $this->timeout],
Expand Down

0 comments on commit 65abdd8

Please sign in to comment.