Redis中快取二進位制資料

81發表於2024-07-27

使用FreeRedis訪問:

byte[] b = File.ReadAllBytes("e:\\3專職安全員C-模擬題庫.pdf");

Stopwatch p = new Stopwatch();
p.Start();
cli.SetRange("key8", 0, b);
cli.Expire("key8", 30);
this.textBox1.Text = p.ElapsedMilliseconds.ToString();

byte[] b2 = cli.GetRange<byte[]>("key8", 0, -1);
cli.Del("key8");
this.textBox2.Text = p.ElapsedMilliseconds.ToString();
File.WriteAllBytes("e:\\3.pdf", b2);

redis 設定expire=0和直接呼叫delete刪除key的區別_redis expire 0-CSDN部落格

因為設定過期時間後,Redis有自己的排程演算法來刪除key,如果確定不用,則最好直接刪除,而不是設定過期時間為0

相關文章