單一資料庫快取的完美解決方案

2021-08-09 20:41:09 字數 799 閱讀 9853

單一資料庫快取的完美解決方案

一 屬性值

cache 設定

readversion

、updateversion

兩個屬性值

二讀操作

1 cache不存在

讀取readversion,未讀到設定為

0,讀取資料庫後,更新

cache內容,

設定readversion

為前面讀到的

readversion。

2 cache 存在

updateversion不存在證明沒有更新操作,直接獲取

cache

的內容。

updateversion 存在則判斷

readversion

和updateversion的值

readversion和

updateversion

相同,表示沒有最新的更新操作,返回

cache

的內容。

readversion和

updateversion

不同,表示有最新更新操作,讀取

updateversion

,取資料庫後,更新

cache內容,

設定readversion

為前面讀取到的

updateversion。

三 寫操作

更新資料庫後,取到updateversion,加

1後儲存。第一次設定

updateversion為1

保證更新資料庫和更新updateversion為同乙個事務

分布式資料庫快取的完美解決方案

分布式資料庫快取的完美解決方案 一 屬性值 資料庫的每張表結構 設定 updatetime欄位 cache 設定readmapupdatetime 表名,updatetime updatemap updatetime 表名,updatetime 的屬性值 readmap updatetime upd...

資料庫亂碼解決方案

oracle 資料庫亂碼解決方案 你插入資料的時候,用 轉變字串的亂碼函式 param str return public string getstr string str catch exception e 向bean裡面賦值 public void setaction string action...

資料庫死鎖解決方案

一 活鎖 如果事務t1封鎖了資料r,事務t2又請求封鎖r,於是t2等待。t3也請求封鎖r,當t1釋放了r上的封鎖之後系統首先批准了t3的請求,t2仍然等待。然後t4又請求封鎖r,當t3釋放了r上的封鎖之後系統又批准了t4的請求,t2有可能永遠等待,這就是活鎖的情形。避免活鎖的簡單方法是採用先來先服務...