mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-09-25 11:32:07 +00:00
* ebean-redisson - initial commit
* Thread.sleep(150) in IntegrationTest - ebean-redisson
* Fix two tenant-aware cache bugs in ebean-redisson + add test coverage
CacheCodec.getMapKeyDecoder() was returning only the tenant portion of
"id:tenantId" Redis field names (substring after the first colon). This
caused every tenant-aware getAll() call to miss: the decoded key did not
match the lookup key, so the DuelCache near-cache warm-up path also
failed to populate.
RedissonCache.getAll() was returning String keys instead of the original
key objects passed in. This broke the ServerCache contract and caused
DuelCache.near.putAll() to store entries under plain strings, making all
subsequent near.get(originalId) calls miss even when the remote cache had
the data.
Additional issues found while reviewing against ebean-redis:
- RServerCacheNotify.notify() was calling listener.notify() locally,
causing a second redundant cache invalidation on the originating node
(ebean-redis does not do this).
- processTableNotify() had no null-guard on listener, risking NPE if a
remote table-mod message arrived before createCacheNotify() was called.
- errorOnWrite() was throwing RuntimeException; cache writes must be
best-effort and only log on failure.
Tests added:
- RedissonCacheTest: direct cache tests for all operations (put/get,
getAll, putAll, remove, removeAll, clear, statistics, TTL, maxSize trim)
- RedissonCacheFactoryTest: factory tests covering cache type creation,
DuelCache for near caches, query-cache singleton, and cross-factory
cluster notification
- CacheCodecTest: key encoder/decoder regression test that pins the
"full string returned" behaviour for both plain and tenant-aware keys
- SerializableCodecTest, VersionGatedCodecTest: codec round-trip tests
- TenantAwareCacheTest: integration test that creates a tenant-aware
Database and verifies that single-bean finds and multi-ID findList()
calls are isolated per tenant at the Redis level
* 18.2.0 - updated version
* RedissonCache/FactoryTest: start Redis container directly in @BeforeAll
Tests were skipped whenever they ran before the integration tests triggered
DB/Redis container startup. Each test class now calls
RedissonTestFixtures.startRedis() (RedisContainer.builder("latest").start())
which is idempotent and requires no other test class to run first.
assumeTrue(isReachable()) remains as a fallback for Docker-less environments.
52 lines
954 B
Java
52 lines
954 B
Java
package org.domain;
|
|
|
|
import io.ebean.Model;
|
|
import io.ebean.annotation.Cache;
|
|
import io.ebean.annotation.CacheBeanTuning;
|
|
import jakarta.persistence.CascadeType;
|
|
import jakarta.persistence.Entity;
|
|
import jakarta.persistence.Id;
|
|
import jakarta.persistence.OneToMany;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.UUID;
|
|
|
|
@Cache(enableQueryCache = true)
|
|
@CacheBeanTuning(maxSecsToLive = 1)
|
|
@Entity
|
|
public class UParent extends Model {
|
|
|
|
@Id
|
|
private UUID id;
|
|
|
|
private String name;
|
|
|
|
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
|
|
private final List<UChild> children = new ArrayList<>();
|
|
|
|
public UParent(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public UUID id() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(UUID id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public String name() {
|
|
return name;
|
|
}
|
|
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public List<UChild> children() {
|
|
return children;
|
|
}
|
|
}
|