forked from docs/doc-exports
Reviewed-by: Mützel, Andrea <andrea.muetzel@t-systems.com> Co-authored-by: Chen, Junjie <chenjunjie@huawei.com> Co-committed-by: Chen, Junjie <chenjunjie@huawei.com>
21 lines
3.3 KiB
HTML
21 lines
3.3 KiB
HTML
<a name="dcs-faq-210531002"></a><a name="dcs-faq-210531002"></a>
|
|
|
|
<h1 class="topictitle1">How Does DCS Delete Expired Keys?</h1>
|
|
<div id="body8662426"><div class="section" id="dcs-faq-210531002__en-us_topic_0000001152183926_section18377173215616"><h4 class="sectiontitle">Question</h4><p id="dcs-faq-210531002__en-us_topic_0000001152183926_p539219381619">What are the rules for scheduled deletion of expired keys on a daily basis? Can I customize the rules?</p>
|
|
</div>
|
|
<div class="section" id="dcs-faq-210531002__en-us_topic_0000001152183926_section18589187786"><h4 class="sectiontitle">Mechanisms for Deleting Expired Keys</h4><ul id="dcs-faq-210531002__en-us_topic_0000001152183926_ul676111019109"><li id="dcs-faq-210531002__en-us_topic_0000001152183926_li6761510131013">Lazy free deletion: The deletion strategy is controlled in the main I/O event loop. Before a read/write command is executed, a function is called to check whether the key to be accessed has expired. If it has expired, it will be deleted and a response will be returned indicating that the key does not exist. If the key has not expired, the command execution resumes.</li><li id="dcs-faq-210531002__en-us_topic_0000001152183926_li96351711151010">Scheduled deletion: A time event function is executed at certain intervals. Each time the function is executed, a random collection of keys are checked, and expired keys are deleted.<div class="note" id="dcs-faq-210531002__en-us_topic_0000001152183926_note184694333100"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="dcs-faq-210531002__en-us_topic_0000001152183926_p346953315107">To avoid prolonged blocks on the Redis main thread, not all keys are checked in each time event. Instead, a random collection of keys are checked each time. As a result, the memory used by expired keys cannot be released quickly.</p>
|
|
</div></div>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="dcs-faq-210531002__en-us_topic_0000001152183926_section454735651113"><h4 class="sectiontitle">Solutions</h4><ul id="dcs-faq-210531002__en-us_topic_0000001152183926_ul9145171671310"><li id="dcs-faq-210531002__en-us_topic_0000001152183926_li1948913317134">Configure scheduled hot key analysis tasks by referring to <a href="dcs-ug-190808001.html#dcs-ug-190808001__section47852016145218">Hot Key Analysis</a>, or use the <strong id="dcs-faq-210531002__en-us_topic_0000001152183926_b1067355655613">SCAN</strong> command to traverse all keys on a scheduled basis and remove expired keys from the memory.</li><li id="dcs-faq-210531002__en-us_topic_0000001152183926_li19583910191613">Configure a scheduled task to scan all master nodes of the instance. All keys will be scanned, and Redis will determine whether the keys have expired. Expired keys will be released. For details, see <a href="dcs-ug-210330002.html">Scanning Expired Keys</a>.</li></ul>
|
|
</div>
|
|
<div class="section" id="dcs-faq-210531002__en-us_topic_0000001152183926_section13981316163316"><h4 class="sectiontitle">How Do I Know Which Expired Keys Have Been Deleted?</h4><p id="dcs-faq-210531002__en-us_topic_0000001152183926_p13848148153312">Deleted expired keys cannot be queried.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dcs-faq-0805001.html">Big/Hot Key Analysis and Expired Key Scan</a></div>
|
|
</div>
|
|
</div>
|
|
|