第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

有沒(méi)有辦法讓 eclipselink/JPA 使用 redis 來(lái)保存和檢索持久單元級(jí)緩存?

有沒(méi)有辦法讓 eclipselink/JPA 使用 redis 來(lái)保存和檢索持久單元級(jí)緩存?

慕工程0101907 2023-07-19 16:08:13
我正在設(shè)置一個(gè)集群環(huán)境,并且希望在整個(gè)集群節(jié)點(diǎn)中復(fù)制 JPA 的二級(jí)緩存。我使用 eclipselink 作為 JPA 提供程序,使用 redis 進(jìn)行緩存管理。
查看完整描述

1 回答

?
ITMISS

TA貢獻(xiàn)1871條經(jīng)驗(yàn) 獲得超8個(gè)贊

沒(méi)有官方或社區(qū)項(xiàng)目支持它。

但是,您可以實(shí)現(xiàn)自己的CacheInterceptor。

例如。

import org.eclipse.persistence.descriptors.ClassDescriptor;

import org.eclipse.persistence.internal.identitymaps.CacheKey;

import org.eclipse.persistence.internal.identitymaps.IdentityMap;

import org.eclipse.persistence.internal.sessions.AbstractSession;

import org.eclipse.persistence.sessions.interceptors.CacheInterceptor;

import org.eclipse.persistence.sessions.interceptors.CacheKeyInterceptor;

import java.util.Map;


public class MyRedisCacheInterceptor extends CacheInterceptor {


? ? private final MyCacheProvider cacheSupport;

? ? private final String cacheName;


? ? public DefaultCacheInterceptor(IdentityMap targetIdentityMap, AbstractSession interceptedSession,

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?String cacheName, DefaultCacheSupport cacheSupport) {

? ? ? ? super(targetIdentityMap, interceptedSession);

? ? ? ? this.cacheSupport = cacheSupport;

? ? ? ? this.cacheName = cacheName;

? ? }


? ? @Override

? ? public Object clone() {

? ? ? ? return null;

? ? }


? ? @Override

? ? protected CacheKeyInterceptor createCacheKeyInterceptor(CacheKey wrappedCacheKey) {

? ? ? ? final long longKey = (long) wrappedCacheKey.getKey();


? ? ? ? CacheKeyInterceptor newKey = new CacheKeyInterceptor(wrappedCacheKey) {

? ? ? ? ? ? @Override

? ? ? ? ? ? public Object getObject() {

? ? ? ? ? ? ? ? return cacheSupport.getOrCreateCache(cacheName).get(longKey);

? ? ? ? ? ? }


? ? ? ? ? ? @Override

? ? ? ? ? ? public void setObject(Object object) {

? ? ? ? ? ? ? ? cacheSupport.getOrCreateCache(cacheName).put(longKey, object);

? ? ? ? ? ? }

? ? ? ? };


? ? ? ? return newKey;

? ? }


? ? @Override

? ? public boolean containsKey(Object primaryKey) {

? ? ? ? return cacheSupport.getOrCreateCache(cacheName).containsKey(primaryKey);

? ? }


? ? @Override

? ? public Map<Object, Object> getAllFromIdentityMapWithEntityPK(Object[] pkList, ClassDescriptor descriptor, AbstractSession session) {

? ? ? ? return null;

? ? }


? ? @Override

? ? public Map<Object, CacheKey> getAllCacheKeysFromIdentityMapWithEntityPK(Object[] pkList, ClassDescriptor descriptor, AbstractSession session) {

? ? ? ? return null;

? ? }


? ? @Override

? ? public void release() {

? ? }

}


查看完整回答
反對(duì) 回復(fù) 2023-07-19
  • 1 回答
  • 0 關(guān)注
  • 121 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)