Skip to content

Commit

Permalink
add support for byte[] in AerospikeCacheKey
Browse files Browse the repository at this point in the history
  • Loading branch information
agrgr committed Jun 20, 2024
1 parent ea4a654 commit 18aaaf1
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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.
*
Expand All @@ -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);
}

}

0 comments on commit 18aaaf1

Please sign in to comment.