Skip to content

Commit

Permalink
chore: ttl should be duration not int
Browse files Browse the repository at this point in the history
  • Loading branch information
bruuuuuuuce committed Dec 21, 2023
1 parent 1f9cb8e commit 87fb164
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/src/cache_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ abstract class ICacheClient {
Future<GetResponse> get(String cacheName, Value value);

Future<SetResponse> set(String cacheName, Value key, Value value,
{int? ttlSeconds});
{Duration? ttl});
}

class CacheClient implements ICacheClient {
Expand All @@ -34,7 +34,7 @@ class CacheClient implements ICacheClient {

@override
Future<SetResponse> set(String cacheName, Value key, Value value,
{int? ttlSeconds}) {
return _dataClient.set(cacheName, key, value, ttlSeconds: ttlSeconds);
{Duration? ttl}) {
return _dataClient.set(cacheName, key, value, ttl: ttl);
}
}
8 changes: 4 additions & 4 deletions lib/src/internal/data_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ abstract class AbstractDataClient {
Future<GetResponse> get(String cacheName, Value key);

Future<SetResponse> set(String cacheName, Value key, Value value,
{int? ttlSeconds});
{Duration? ttl});
}

class DataClient implements AbstractDataClient {
Expand Down Expand Up @@ -64,12 +64,12 @@ class DataClient implements AbstractDataClient {

@override
Future<SetResponse> set(String cacheName, Value key, Value value,
{int? ttlSeconds}) async {
{Duration? ttl}) async {
var request = SetRequest_();
request.cacheKey = key.toBinary();
request.cacheBody = value.toBinary();
request.ttlMilliseconds = (ttlSeconds != null
? ttlSeconds * 1000
request.ttlMilliseconds = (ttl != null
? ttl.inMilliseconds
: _defaultTtl.inMilliseconds) as Int64;
try {
await _client.set(request,
Expand Down

0 comments on commit 87fb164

Please sign in to comment.