From d6294ad60133b3a0752c40c72d0ef55ed1f4dcdd Mon Sep 17 00:00:00 2001 From: Daniil Solovyov Date: Thu, 18 Apr 2024 08:28:19 +0200 Subject: [PATCH] IUntillDbStorageApi: updates (#103) https://dev.untill.com/projects/#!687090 Co-authored-by: sda --- .../dbstorage/IUntillDbStorageApi.java | 21 ++++++++++++++ .../untillapi/dbstorage/StorageItem.java | 28 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/main/java/com/untill/driver/untillapi/dbstorage/StorageItem.java diff --git a/src/main/java/com/untill/driver/untillapi/dbstorage/IUntillDbStorageApi.java b/src/main/java/com/untill/driver/untillapi/dbstorage/IUntillDbStorageApi.java index c73b134..4a55299 100644 --- a/src/main/java/com/untill/driver/untillapi/dbstorage/IUntillDbStorageApi.java +++ b/src/main/java/com/untill/driver/untillapi/dbstorage/IUntillDbStorageApi.java @@ -3,6 +3,8 @@ import com.untill.driver.IDriverContext; import com.untill.driver.untillapi.IUntillApi; +import java.util.List; + /** * UntillAPI allows to write/read data bytes to/from DB by driver configuration GUID and key. * @@ -49,6 +51,15 @@ public interface IUntillDbStorageApi extends IUntillApi { */ byte[] read(String configurationGuid, String key); + /** + * Returns the list of the data entries, written by any of the driver instances in network (same driverId!) + * + * @param thisConfigurationGuid driver configuration GUID + * @param key data key + * @return list of {@link StorageItem storage items} + */ + List readFromAllConfigs(String thisConfigurationGuid, String key); + /** * Write data bytes by driver configuration GUID and key * @@ -57,4 +68,14 @@ public interface IUntillDbStorageApi extends IUntillApi { * @param data data bytes */ void write(String configurationGuid, String key, byte[] data); + + /** + * Write data bytes by driver configuration GUID and key with expiry date + * + * @param configurationGuid driver configuration GUID + * @param key data key + * @param data data bytes + * @param expiryDate unix timestamp in milliseconds + */ + void write(String configurationGuid, String key, byte[] data, long expiryDate); } \ No newline at end of file diff --git a/src/main/java/com/untill/driver/untillapi/dbstorage/StorageItem.java b/src/main/java/com/untill/driver/untillapi/dbstorage/StorageItem.java new file mode 100644 index 0000000..bacfd98 --- /dev/null +++ b/src/main/java/com/untill/driver/untillapi/dbstorage/StorageItem.java @@ -0,0 +1,28 @@ +package com.untill.driver.untillapi.dbstorage; + +public class StorageItem { + /** + * Driver configuration GUID + */ + private String configurationGuid; + /** + * Data bytes + */ + private byte[] data; + + public String getConfigurationGuid() { + return configurationGuid; + } + + public void setConfigurationGuid(String configurationGuid) { + this.configurationGuid = configurationGuid; + } + + public byte[] getData() { + return data; + } + + public void setData(byte[] data) { + this.data = data; + } +}