久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <legend id='df88n'><style id='df88n'><dir id='df88n'><q id='df88n'></q></dir></style></legend>

    1. <i id='df88n'><tr id='df88n'><dt id='df88n'><q id='df88n'><span id='df88n'><b id='df88n'><form id='df88n'><ins id='df88n'></ins><ul id='df88n'></ul><sub id='df88n'></sub></form><legend id='df88n'></legend><bdo id='df88n'><pre id='df88n'><center id='df88n'></center></pre></bdo></b><th id='df88n'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='df88n'><tfoot id='df88n'></tfoot><dl id='df88n'><fieldset id='df88n'></fieldset></dl></div>
    2. <small id='df88n'></small><noframes id='df88n'>

      <tfoot id='df88n'></tfoot>
        <bdo id='df88n'></bdo><ul id='df88n'></ul>
    3. 將 Redis 數據同步到 MySQL 的最佳策略是什么?

      What#39;s the best strategy to sync Redis data to MySQL?(將 Redis 數據同步到 MySQL 的最佳策略是什么?)
      <legend id='JPVnW'><style id='JPVnW'><dir id='JPVnW'><q id='JPVnW'></q></dir></style></legend>
      1. <i id='JPVnW'><tr id='JPVnW'><dt id='JPVnW'><q id='JPVnW'><span id='JPVnW'><b id='JPVnW'><form id='JPVnW'><ins id='JPVnW'></ins><ul id='JPVnW'></ul><sub id='JPVnW'></sub></form><legend id='JPVnW'></legend><bdo id='JPVnW'><pre id='JPVnW'><center id='JPVnW'></center></pre></bdo></b><th id='JPVnW'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='JPVnW'><tfoot id='JPVnW'></tfoot><dl id='JPVnW'><fieldset id='JPVnW'></fieldset></dl></div>

        <small id='JPVnW'></small><noframes id='JPVnW'>

          <tbody id='JPVnW'></tbody>
        • <tfoot id='JPVnW'></tfoot>

            <bdo id='JPVnW'></bdo><ul id='JPVnW'></ul>

                本文介紹了將 Redis 數據同步到 MySQL 的最佳策略是什么?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                1. 用例是使用Redis作為MySQL的本地緩存
                2. MySQL 中的數據格式是:一個主鍵和幾個其他字段.不會有db的跨表查詢
                3. Redis key 是 MySQL 中的主鍵,value 是包含 MySQL 中其他字段的 hash
                4. 斷電時,數據丟失少于一分鐘是可以接受的.

                我的解決方案是:

                1. Redis 寫入 AOF 文件,某些進程會監視此文件并將更新的數據同步到 MySQL
                2. Hack Redis 將 AOF 寫在多個文件中,就像 MySQL binlog 一樣
                3. 數據接口只會通過Redis讀寫

                這個解決方案好嗎?
                完成這項工作的最佳策略是什么?

                Is this solution OK?
                And what's the best strategy to do this job?

                推薦答案

                你不需要破解任何東西 ;)

                You don't need to hack anything ;)

                我不完全確定您為什么需要 mysql 上的數據.如果我知道,也許會有更合適的答案.在任何情況下,作為通用答案,您可以使用 redis 鍵空間通知

                I am not entirely sure why you need the data on mysql. If I knew, maybe there would be a more suitable answer. In any case, as a generic answer you can use redis keyspace notifications

                您可以在您的密鑰上訂閱命令 HSET、HMSET、HDEL 和 DEL,這樣每次刪除密鑰或設置或刪除哈希值時您都會收到通知.

                You could subscribe to the commands HSET, HMSET, HDEL and DEL on your keys, so you would get a notification everytime a key is deleted or a hash value is set or removed.

                請注意,如果您錯過任何通知,就會出現不一致的情況.因此,偶爾您可以使用 SCAN 命令查看所有密鑰并檢查 mysql 是否需要更新.

                Note if you miss any notification you would have an inconsistency. So once in a while you could just use the SCAN command to go through all your keys and check on mysql if they need to be updated.

                另一種策略可能是維護兩個獨立的結構.一個是帶有值的散列,另一個是按更新時間戳排序的所有值的 ZSET.保持這兩種結構最新的最好方法是編寫兩個或三個 lua 腳本(插入/更新和刪除),它們將原子地操作散列和 zset.

                Another strategy could be maintaining two separate structures. One would be the hash with the values, and the other would be a ZSET of all the values sorted by timestamp of update. The best way to keep both structures up to date would be to write two or three lua scripts (insert/update and delete) that would operate on the hash and the zset atomically.

                然后,您可以定期查詢 ZSET 中時間戳高于上次同步操作的元素,獲取所有更新的鍵(它將包括已刪除的鍵,除非您想為這些鍵保留第二個 ZSET)然后只需通過鍵檢索所有元素并同步到mysql.

                Then you can just periodically query the ZSET for the elements with a timestamp higher than your last sync operation, get all the keys that were updated (it would include deleted keys, unless you want to keep a second ZSET exclusively for those) and then just retrieve all the elements by key and sync to mysql.

                希望它對你有用!

                這篇關于將 Redis 數據同步到 MySQL 的最佳策略是什么?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函數根據 N 個先前值來決定接下來的 N 個行)
                reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用選擇表達式的結果;條款?)
                Does ignore option of Pyspark DataFrameWriter jdbc function ignore entire transaction or just offending rows?(Pyspark DataFrameWriter jdbc 函數的 ignore 選項是忽略整個事務還是只是有問題的行?) - IT屋-程序員軟件開發技
                Error while using INSERT INTO table ON DUPLICATE KEY, using a for loop array(使用 INSERT INTO table ON DUPLICATE KEY 時出錯,使用 for 循環數組)
                pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 調用 o23.load 時發生錯誤 沒有合適的驅動程序)
                How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe?(如何將 Apache Spark 與 MySQL 集成以將數據庫表作為 Spark 數據幀讀取?)
              1. <legend id='ziWtU'><style id='ziWtU'><dir id='ziWtU'><q id='ziWtU'></q></dir></style></legend>

                    <i id='ziWtU'><tr id='ziWtU'><dt id='ziWtU'><q id='ziWtU'><span id='ziWtU'><b id='ziWtU'><form id='ziWtU'><ins id='ziWtU'></ins><ul id='ziWtU'></ul><sub id='ziWtU'></sub></form><legend id='ziWtU'></legend><bdo id='ziWtU'><pre id='ziWtU'><center id='ziWtU'></center></pre></bdo></b><th id='ziWtU'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ziWtU'><tfoot id='ziWtU'></tfoot><dl id='ziWtU'><fieldset id='ziWtU'></fieldset></dl></div>
                      <tbody id='ziWtU'></tbody>
                  1. <small id='ziWtU'></small><noframes id='ziWtU'>

                      <tfoot id='ziWtU'></tfoot>

                        <bdo id='ziWtU'></bdo><ul id='ziWtU'></ul>
                        1. 主站蜘蛛池模板: 精品少妇一区二区三区在线播放 | 国产免费麻豆视频 | 就操在线| 国产精品国产三级国产播12软件 | 日日天天 | 国产va | 日韩在线免费播放 | 日韩免费av| 亚洲视频免费在线观看 | 在线视频h| 91久久国产综合久久91精品网站 | 国产成人a亚洲精品 | www.性色 | 99re热精品视频国产免费 | 色综合成人网 | 亚洲国产精品一区二区三区 | 一区二区三区av | 久久久免费 | 免费国产精品久久久久久 | 欧美日韩精品一区 | 极品销魂美女一区二区 | 免费亚洲成人 | 在线成人免费视频 | 欧美一级欧美一级在线播放 | 日韩一区二区三区视频 | 久久人人网 | 日韩国产中文字幕 | 亚洲精品9999 | 日韩欧美视频免费在线观看 | 蜜桃传媒av| 久久久久久国产免费视网址 | 精品一区二区三 | 国产成人精品一区二 | 欧洲成人免费视频 | 成人午夜黄色 | 国产亚洲网站 | 欧美精品久久久久久久久久 | 韩国av一区二区 | 夜夜爽99久久国产综合精品女不卡 | 天堂综合网 | www国产亚洲精品 |