-
Notifications
You must be signed in to change notification settings - Fork 5
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
chore: make $refreshTtl
optional and re-order arguments for list push and dictionary increment
#77
Conversation
…t list push operations and dictionary increment operation; updates tests accordingly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@poppoerika if you want to merge this as an incremental PR it looks good to me, but before we close #49 I wanted to make it conform to the pattern we established in the .NET repo, like this:
@cprice404 |
Good question. It's just there for API symmetry, in case people want to write very explicit code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i just have a couple of minor nits and then I'm +1. We should probably also get Pete to take a quick peek when he's back tomorrow.
src/Cache/_ScsDataClient.php
Outdated
@@ -175,6 +177,14 @@ private function ttlToMillis(?int $ttl = null): int | |||
return $ttl * 1000; | |||
} | |||
|
|||
private function returnCollectionTtl($ttl): CollectionTtl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we annotate tye type of the argument here? I believe it would be ?CollectionTtl
?
src/Requests/CollectionTtl.php
Outdated
|
||
class CollectionTtl | ||
{ | ||
private ?int $ttl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are using integers to represent ttls, the variable names need to include the unit for clarity. I think we were using ttlSeconds
in the previous code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✨ 🚢 from me!
but let's let pete take a quick peek
src/Cache/SimpleCacheClient.php
Outdated
@@ -143,9 +144,9 @@ public function listErase(string $cacheName, string $listName, ?int $beginIndex | |||
return $this->dataClient->listErase($cacheName, $listName, $beginIndex, $count); | |||
} | |||
|
|||
public function dictionarySetField(string $cacheName, string $dictionaryName, string $field, string $value, bool $refreshTtl, ?int $ttlSeconds = null): CacheDictionarySetFieldResponse | |||
public function dictionarySetField(string $cacheName, string $dictionaryName, string $field, string $value, CollectionTtl $ttl = null): CacheDictionarySetFieldResponse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer the CollectionTtl
parameter be explicitly nullable in all of these functions:
public function dictionarySetField(string $cacheName, string $dictionaryName, string $field, string $value, CollectionTtl $ttl = null): CacheDictionarySetFieldResponse | |
public function dictionarySetField(string $cacheName, string $dictionaryName, string $field, string $value, ?CollectionTtl $ttl = null): CacheDictionarySetFieldResponse |
It looks like the null assignment does that implicitly, but I think making it explicit and consistent with the rest of our nullable parameters will make it more readable and maintainable.
src/Cache/_ScsDataClient.php
Outdated
@@ -271,18 +281,19 @@ public function listFetch(string $cacheName, string $listName): CacheListFetchRe | |||
} | |||
|
|||
public function listPushFront( | |||
string $cacheName, string $listName, string $value, bool $refreshTtl, ?int $truncateBackToSize = null, ?int $ttlSeconds = null | |||
string $cacheName, string $listName, string $value, ?int $truncateBackToSize = null, CollectionTtl $ttl = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above: please make all the CollectionTtl parameters in this file explicitly nullable ?CollectionTtl
instead.
src/Requests/CollectionTtl.php
Outdated
return new CollectionTtl(null, true); | ||
} | ||
|
||
public static function of(int $ttl): CollectionTtl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd prefer this parameter to match the constructor and be called $ttlSeconds
instead, so the unit is explicit in the parameter name (and in the named parameter label). I know I personally get confused about when we're using seconds vs. millis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! I made a couple small suggestions.
…to ?CollectionTtl; chore: rename of param to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thanks you!
$refreshTtl
optional and default totrue
.$trunncateFrontToSie
,$truncateBackToSize
, andamount
are before$refreshTtl
.This PR needs to get merged before working on #54.
Closes #49
Closes #50