{"id":205,"date":"2018-04-25T14:29:39","date_gmt":"2018-04-25T22:29:39","guid":{"rendered":"http:\/\/www.gauntletwizard.net\/wordpress\/?p=205"},"modified":"2018-04-25T21:15:06","modified_gmt":"2018-04-26T05:15:06","slug":"delete-keys-in-redis-non-atomically","status":"publish","type":"post","link":"https:\/\/www.gauntletwizard.net\/wordpress\/?p=205","title":{"rendered":"Delete keys in redis non-atomically"},"content":{"rendered":"<p>There&#8217;s a lot of information out there about how to atomically delete a sequence of keys in Redis. That&#8217;s great, if you want to cause your production cluster to block for minutes at a time while you do so. If you&#8217;ve want to delete a bunch of keys with a scan, though, there&#8217;s less info.<\/p>\n<p>redis-cli does support a <code>--scan<\/code> flag, which combined with a <code>--pattern<\/code> flag allows you to asynchronously list a set of prefixed keys &#8211; Like the <code>keys<\/code> command, except without causing your redis server to block. You can then use this output to feed an xargs command.<\/p>\n<p>For example: <code>redis-cli --scan -h \"${REDISHOST}\" --pattern \"PATTERN\" | tee keys | xargs redis-cli -h \"${REDISHOST}\" del | tee deletions<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>There&#8217;s a lot of information out there about how to atomically delete a sequence of keys in Redis. That&#8217;s great, if you want to cause your production cluster to block for minutes at a time while you do so. If you&#8217;ve want to delete a bunch of keys with a scan, though, there&#8217;s less info. &hellip; <a href=\"https:\/\/www.gauntletwizard.net\/wordpress\/?p=205\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Delete keys in redis non-atomically<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/205"}],"collection":[{"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=205"}],"version-history":[{"count":3,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/205\/revisions"}],"predecessor-version":[{"id":209,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/205\/revisions\/209"}],"wp:attachment":[{"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}