Skip to content

Commit

Permalink
Binary -> Bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
anitarua committed Jan 11, 2024
1 parent 48ee796 commit a3cfc0f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 40 deletions.
15 changes: 10 additions & 5 deletions example/doc_example_apis/doc_example_apis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Future<void> example_API_InstantiateCacheClient() async {
}
}

Future<void> example_API_CreateCache(CacheClient cacheClient, String cacheName) async {
Future<void> example_API_CreateCache(
CacheClient cacheClient, String cacheName) async {
final result = await cacheClient.createCache(cacheName);
switch (result) {
case CreateCacheAlreadyExists():
Expand All @@ -36,7 +37,8 @@ Future<void> example_API_ListCaches(CacheClient cacheClient) async {
}
}

Future<void> example_API_DeleteCache(CacheClient cacheClient, String cacheName) async {
Future<void> example_API_DeleteCache(
CacheClient cacheClient, String cacheName) async {
final result = await cacheClient.deleteCache(cacheName);
switch (result) {
case DeleteCacheError():
Expand All @@ -47,7 +49,8 @@ Future<void> example_API_DeleteCache(CacheClient cacheClient, String cacheName)
}
}

Future<void> example_API_Set(CacheClient cacheClient, String cacheName, String key, String value) async {
Future<void> example_API_Set(
CacheClient cacheClient, String cacheName, String key, String value) async {
final result = await cacheClient.set(cacheName, key, value);
switch (result) {
case SetError():
Expand All @@ -58,7 +61,8 @@ Future<void> example_API_Set(CacheClient cacheClient, String cacheName, String k
}
}

Future<void> example_API_Get(CacheClient cacheClient, String cacheName, String key) async {
Future<void> example_API_Get(
CacheClient cacheClient, String cacheName, String key) async {
final result = await cacheClient.get(cacheName, key);
switch (result) {
case GetMiss():
Expand All @@ -70,7 +74,8 @@ Future<void> example_API_Get(CacheClient cacheClient, String cacheName, String k
}
}

Future<void> example_API_Delete(CacheClient cacheClient, String cacheName, String key) async {
Future<void> example_API_Delete(
CacheClient cacheClient, String cacheName, String key) async {
final result = await cacheClient.delete(cacheName, key);
switch (result) {
case DeleteError():
Expand Down
62 changes: 31 additions & 31 deletions lib/src/cache_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ abstract class ICacheClient {
Future<SetResponse> set(String cacheName, String key, String value,
{Duration? ttl});

Future<SetResponse> setBinary(String cacheName, String key, List<int> value,
Future<SetResponse> setBytes(String cacheName, String key, List<int> value,
{Duration? ttl});

Future<DeleteResponse> delete(String cacheName, String key);
Expand All @@ -31,15 +31,15 @@ abstract class ICacheClient {
String cacheName, String listName, List<String> values,
{CollectionTtl? ttl, int? truncateFrontToSize});

Future<ListConcatenateBackResponse> listConcatenateBackBinary(
Future<ListConcatenateBackResponse> listConcatenateBackBytes(
String cacheName, String listName, List<List<int>> values,
{CollectionTtl? ttl, int? truncateFrontToSize});

Future<ListConcatenateFrontResponse> listConcatenateFront(
String cacheName, String listName, List<String> values,
{CollectionTtl? ttl, int? truncateBackToSize});

Future<ListConcatenateFrontResponse> listConcatenateFrontBinary(
Future<ListConcatenateFrontResponse> listConcatenateFrontBytes(
String cacheName, String listName, List<List<int>> values,
{CollectionTtl? ttl, int? truncateBackToSize});

Expand All @@ -53,22 +53,22 @@ abstract class ICacheClient {
String cacheName, String listName, String value,
{CollectionTtl? ttl, int? truncateFrontToSize});

Future<ListPushBackResponse> listPushBackBinary(
Future<ListPushBackResponse> listPushBackBytes(
String cacheName, String listName, List<int> value,
{CollectionTtl? ttl, int? truncateFrontToSize});

Future<ListPushFrontResponse> listPushFront(
String cacheName, String listName, String value,
{CollectionTtl? ttl, int? truncateBackToSize});

Future<ListPushFrontResponse> listPushFrontBinary(
Future<ListPushFrontResponse> listPushFrontBytes(
String cacheName, String listName, List<int> value,
{CollectionTtl? ttl, int? truncateBackToSize});

Future<ListRemoveValueResponse> listRemoveValue(
String cacheName, String listName, String value);

Future<ListRemoveValueResponse> listRemoveValueBinary(
Future<ListRemoveValueResponse> listRemoveValueBytes(
String cacheName, String listName, List<int> value);

Future<ListRetainResponse> listRetain(String cacheName, String listName,
Expand Down Expand Up @@ -226,7 +226,7 @@ class CacheClient implements ICacheClient {
/// }
/// ```
@override
Future<SetResponse> setBinary(String cacheName, String key, List<int> value,
Future<SetResponse> setBytes(String cacheName, String key, List<int> value,
{Duration? ttl}) {
return _doSet(cacheName, StringValue(key), BinaryValue(value), ttl: ttl);
}
Expand Down Expand Up @@ -274,8 +274,8 @@ class CacheClient implements ICacheClient {
}

/// Adds multiple elements to the back of the given list. Creates the list if it does not already exist.
///
///
///
///
/// Provide a [ttl] to set a time-to-live for the list (see [CollectionTtl] for more details).
/// Provide [truncateFrontToSize] to truncate the list to the given size after the concatenation.
/// Returns a response that can be resolved to one of its possible types:
Expand All @@ -297,8 +297,8 @@ class CacheClient implements ICacheClient {
}

/// Adds multiple elements to the back of the given list. Creates the list if it does not already exist.
///
///
///
///
/// Provide a [ttl] to set a time-to-live for the list (see [CollectionTtl] for more details).
/// Provide [truncateFrontToSize] to truncate the list to the given size after the concatenation.
/// Returns a response that can be resolved to one of its possible types:
Expand All @@ -311,7 +311,7 @@ class CacheClient implements ICacheClient {
/// }
/// ```
@override
Future<ListConcatenateBackResponse> listConcatenateBackBinary(
Future<ListConcatenateBackResponse> listConcatenateBackBytes(
String cacheName, String listName, List<List<int>> values,
{CollectionTtl? ttl, int? truncateFrontToSize}) {
return _doListConcatenateBack(
Expand All @@ -338,8 +338,8 @@ class CacheClient implements ICacheClient {
}

/// Adds multiple elements to the front of the given list. Creates the list if it does not already exist.
///
///
///
///
/// Provide a [ttl] to set a time-to-live for the list (see [CollectionTtl] for more details).
/// Provide [truncateBackToSize] to truncate the list to the given size after the concatenation.
/// Returns a response that can be resolved to one of its possible types:
Expand All @@ -361,8 +361,8 @@ class CacheClient implements ICacheClient {
}

/// Adds multiple elements to the front of the given list. Creates the list if it does not already exist.
///
///
///
///
/// Provide a [ttl] to set a time-to-live for the list (see [CollectionTtl] for more details).
/// Provide [truncateBackToSize] to truncate the list to the given size after the concatenation.
/// Returns a response that can be resolved to one of its possible types:
Expand All @@ -375,7 +375,7 @@ class CacheClient implements ICacheClient {
/// }
/// ```
@override
Future<ListConcatenateFrontResponse> listConcatenateFrontBinary(
Future<ListConcatenateFrontResponse> listConcatenateFrontBytes(
String cacheName, String listName, List<List<int>> values,
{CollectionTtl? ttl, int? truncateBackToSize}) {
return _doListConcatenateFront(
Expand All @@ -402,7 +402,7 @@ class CacheClient implements ICacheClient {
}

/// Fetches all elements of the given list.
///
///
/// Provide [startIndex] (inclusive) and [endIndex] (exclusive) to fetch a subset of the list.
/// Returns a response that can be resolved to one of its possible types:
/// ```dart
Expand Down Expand Up @@ -434,7 +434,7 @@ class CacheClient implements ICacheClient {
}

/// Gets the number of elements in the given list.
///
///
/// Returns a response that can be resolved to one of its possible types:
/// ```dart
/// switch(response) {
Expand Down Expand Up @@ -463,7 +463,7 @@ class CacheClient implements ICacheClient {
}

/// Gets and removes the last value from the given list.
///
///
/// Returns a response that can be resolved to one of its possible types:
/// ```dart
/// switch(response) {
Expand Down Expand Up @@ -492,7 +492,7 @@ class CacheClient implements ICacheClient {
}

/// Gets and removes the first value from the given list.
///
///
/// Returns a response that can be resolved to one of its possible types:
/// ```dart
/// switch(response) {
Expand Down Expand Up @@ -521,7 +521,7 @@ class CacheClient implements ICacheClient {
}

/// Adds an element to the back of the given list. Creates the list if it does not already exist.
///
///
/// Provide a [ttl] to set a time-to-live for the list (see [CollectionTtl] for more details).
/// Provide [truncateFrontToSize] to truncate the list to the given size after the operation.
/// Returns a response that can be resolved to one of its possible types:
Expand All @@ -542,7 +542,7 @@ class CacheClient implements ICacheClient {
}

/// Adds an element to the back of the given list. Creates the list if it does not already exist.
///
///
/// Provide a [ttl] to set a time-to-live for the list (see [CollectionTtl] for more details).
/// Provide [truncateFrontToSize] to truncate the list to the given size after the operation.
/// Returns a response that can be resolved to one of its possible types:
Expand All @@ -555,7 +555,7 @@ class CacheClient implements ICacheClient {
/// }
/// ```
@override
Future<ListPushBackResponse> listPushBackBinary(
Future<ListPushBackResponse> listPushBackBytes(
String cacheName, String listName, List<int> value,
{CollectionTtl? ttl, int? truncateFrontToSize}) {
return _doListPushBack(cacheName, listName, BinaryValue(value),
Expand All @@ -581,7 +581,7 @@ class CacheClient implements ICacheClient {
}

/// Adds an element to the front of the given list. Creates the list if it does not already exist.
///
///
/// Provide a [ttl] to set a time-to-live for the list (see [CollectionTtl] for more details).
/// Provide [truncateBackToSize] to truncate the list to the given size after the operation.
/// Returns a response that can be resolved to one of its possible types:
Expand All @@ -602,7 +602,7 @@ class CacheClient implements ICacheClient {
}

/// Adds an element to the front of the given list. Creates the list if it does not already exist.
///
///
/// Provide a [ttl] to set a time-to-live for the list (see [CollectionTtl] for more details).
/// Provide [truncateBackToSize] to truncate the list to the given size after the operation.
/// Returns a response that can be resolved to one of its possible types:
Expand All @@ -615,7 +615,7 @@ class CacheClient implements ICacheClient {
/// }
/// ```
@override
Future<ListPushFrontResponse> listPushFrontBinary(
Future<ListPushFrontResponse> listPushFrontBytes(
String cacheName, String listName, List<int> value,
{CollectionTtl? ttl, int? truncateBackToSize}) {
return _doListPushFront(cacheName, listName, BinaryValue(value),
Expand All @@ -641,7 +641,7 @@ class CacheClient implements ICacheClient {
}

/// Removes all elements from the given list equal to the given value.
///
///
/// Returns a response that can be resolved to one of its possible types:
/// ```dart
/// switch(response) {
Expand All @@ -658,7 +658,7 @@ class CacheClient implements ICacheClient {
}

/// Removes all elements from the given list equal to the given value.
///
///
/// Returns a response that can be resolved to one of its possible types:
/// ```dart
/// switch(response) {
Expand All @@ -669,7 +669,7 @@ class CacheClient implements ICacheClient {
/// }
/// ```
@override
Future<ListRemoveValueResponse> listRemoveValueBinary(
Future<ListRemoveValueResponse> listRemoveValueBytes(
String cacheName, String listName, List<int> value) {
return _doListRemoveValue(cacheName, listName, BinaryValue(value));
}
Expand All @@ -691,7 +691,7 @@ class CacheClient implements ICacheClient {
}

/// Retains slice of elements of a given list, deletes the rest of the list that isn't being retained.
///
///
/// Provide a [ttl] to set a time-to-live for the list (see [CollectionTtl] for more details).
/// Provide [startIndex] (inclusive) and [endIndex] (exclusive) to specify a subset of the list to retain.
/// Returns a response that can be resolved to one of its possible types:
Expand Down
8 changes: 4 additions & 4 deletions lib/src/topic_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ abstract class ITopicClient {
Future<TopicPublishResponse> publish(
String cacheName, String topicName, String value);

Future<TopicPublishResponse> publishBinary(
Future<TopicPublishResponse> publishBytes(
String cacheName, String topicName, List<int> value);

Future<TopicSubscribeResponse> subscribe(String cacheName, String topicName);
Expand Down Expand Up @@ -40,7 +40,7 @@ class TopicClient implements ITopicClient {

/// Publish a value to a topic.
///
/// Publishes a string [value] to a topic specified by [topicName] which exists on a cache
/// Publishes a [value] to a topic specified by [topicName] which exists on a cache
/// specified by [cacheName].
/// Returns a response that can be resolved to one of its possible types:
/// ```dart
Expand All @@ -59,7 +59,7 @@ class TopicClient implements ITopicClient {

/// Publish a value to a topic.
///
/// Publishes a binary [value] to a topic specified by [topicName] which exists on a cache
/// Publishes a [value] to a topic specified by [topicName] which exists on a cache
/// specified by [cacheName].
/// Returns a response that can be resolved to one of its possible types:
/// ```dart
Expand All @@ -71,7 +71,7 @@ class TopicClient implements ITopicClient {
/// }
/// ```
@override
Future<TopicPublishResponse> publishBinary(
Future<TopicPublishResponse> publishBytes(
String cacheName, String topicName, List<int> value) {
return _doPublish(cacheName, topicName, BinaryValue(value));
}
Expand Down

0 comments on commit a3cfc0f

Please sign in to comment.