From 18aaaf1dc75989bfa0598e3ab97739c5726b679b Mon Sep 17 00:00:00 2001 From: agrgr Date: Thu, 20 Jun 2024 14:27:29 +0300 Subject: [PATCH] add support for byte[] in AerospikeCacheKey --- .../data/aerospike/cache/AerospikeCacheKey.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/springframework/data/aerospike/cache/AerospikeCacheKey.java b/src/main/java/org/springframework/data/aerospike/cache/AerospikeCacheKey.java index 86a80a6ba..e4542d7c8 100644 --- a/src/main/java/org/springframework/data/aerospike/cache/AerospikeCacheKey.java +++ b/src/main/java/org/springframework/data/aerospike/cache/AerospikeCacheKey.java @@ -4,7 +4,7 @@ import lombok.Getter; /** - * Wrapper class used for caching with methods that receive either a String or a long number + * Wrapper class used in caching. Receives hash of the cache key as a String, a long number or a byte array. */ public class AerospikeCacheKey { @@ -19,6 +19,10 @@ private AerospikeCacheKey(long number) { this.value = new Value.LongValue(number); } + private AerospikeCacheKey(byte[] data) { + this.value = new Value.BytesValue(data); + } + /** * Instantiate AerospikeCacheKey instance with a String. * @@ -38,4 +42,15 @@ public static AerospikeCacheKey of(String string) { public static AerospikeCacheKey of(long number) { return new AerospikeCacheKey(number); } + + /** + * Instantiate AerospikeCacheKey instance with a byte array. + * + * @param data byte array + * @return new instance of AerospikeCacheKey initialized with the given parameter + */ + public static AerospikeCacheKey of(byte[] data) { + return new AerospikeCacheKey(data); + } + }