Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FMWK-459 Fix requiring id property from entities by AerospikeCache #752

Merged
merged 24 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d99e2a2
Set data key in AerospikeCache
agrgr Jun 10, 2024
a27d434
add tests
agrgr Jun 10, 2024
cc0ebaf
use hashCode userKey instead of String in AerospikeCache, add tests
agrgr Jun 10, 2024
3e301e6
cleanup
agrgr Jun 11, 2024
c8c970c
use hash code of key class when its object empty, add tests
agrgr Jun 13, 2024
9eefab6
cleanup
agrgr Jun 13, 2024
15ba1ca
use toString + hashCode() when key is empty for consistency
agrgr Jun 13, 2024
4c9014e
use toString + hashCode() when key is empty for consistency
agrgr Jun 13, 2024
6bb851b
add using Kryo to serialize cached objects
agrgr Jun 16, 2024
bd1d7f8
add a test
agrgr Jun 16, 2024
b998979
replace hash implementation with a faster one, make serialization and…
agrgr Jun 17, 2024
84310ec
javadoc update
agrgr Jun 17, 2024
9697cb0
replace hashing algorithm for cache key
agrgr Jun 18, 2024
e72f8e1
Merge branch 'main' into FMWK-459-cache-entities-without-id
agrgr Jun 18, 2024
0b04b9f
convert AerospikeCacheKeyProcessor into an interface
agrgr Jun 19, 2024
d650583
convert AerospikeCacheKeyProcessor into an interface
agrgr Jun 19, 2024
2e14355
convert AerospikeCacheKeyProcessor into an interface
agrgr Jun 19, 2024
703ac9e
add a test for null key
agrgr Jun 19, 2024
35aad25
create AerospikeCacheKeyProcessor bean to enable overriding it with a…
agrgr Jun 19, 2024
4bc70aa
remove unused configuration
agrgr Jun 19, 2024
d65c93f
convert AerospikeCacheKeyProcessor into an interface
agrgr Jun 19, 2024
ac3fff2
update javadoc
agrgr Jun 20, 2024
ea4a654
update documentation
agrgr Jun 20, 2024
18aaaf1
add support for byte[] in AerospikeCacheKey
agrgr Jun 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.aerospike.client.policy.RecordExistsAction;
import com.aerospike.client.policy.WritePolicy;
import org.springframework.cache.Cache;
import org.springframework.cache.interceptor.SimpleKey;
import org.springframework.cache.support.SimpleValueWrapper;
import org.springframework.data.aerospike.convert.AerospikeConverter;
import org.springframework.data.aerospike.convert.AerospikeReadData;
Expand Down Expand Up @@ -196,12 +197,18 @@ public ValueWrapper putIfAbsent(Object key, Object value) {
}

private Key getKey(Object key) {
return new Key(cacheConfiguration.getNamespace(), cacheConfiguration.getSet(), key.toString());
int userKey = (key instanceof SimpleKey && key.equals(SimpleKey.EMPTY))
// return hash code of key's class (hash code of key itself can be equal to 1) when no arguments are given
? key.getClass().hashCode()
: key.hashCode();
return new Key(cacheConfiguration.getNamespace(), cacheConfiguration.getSet(), userKey);
}

private void serializeAndPut(WritePolicy writePolicy, Object key, Object value) {
AerospikeWriteData data = AerospikeWriteData.forWrite(getKey(key).namespace);
AerospikeWriteData data = AerospikeWriteData.forWrite(cacheConfiguration.getNamespace());
Key aerospikeKey = getKey(key);
data.setKey(aerospikeKey); // Set the key on the data object
aerospikeConverter.write(value, data);
client.put(writePolicy, getKey(key), data.getBinsAsArray());
client.put(writePolicy, aerospikeKey, data.getBinsAsArray());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public abstract class BaseIntegrationTests {

public static final String DEFAULT_SET_NAME = "aerospike";
public static final String OVERRIDE_SET_NAME = "testSet1";
public static final String DIFFERENT_SET_NAME = "different-set";
public static final String CACHE_WITH_TTL = "CACHE-WITH-TTL";
public static final String DIFFERENT_EXISTING_CACHE = "DIFFERENT-EXISTING-CACHE";
protected static final int MILLIS_TO_NANO = 1_000_000;

@Value("${spring-data-aerospike.connection.namespace}")
Expand Down
Loading
Loading