發表文章

目前顯示的是有「Redis」標籤的文章

Markdown

[Redis] How to Delete multiple keys

redis DEL delete-multiple-keys https://stackoverflow.com/questions/40678022/redis-cli-delete-multiple-keys redis - cli -- scan -- pattern 'Product:*:*' | xargs redis - cli DEL

[Redis] Redis setup hints & Redis latency problems troubleshooting

Redis setup hints https://redis.io/topics/admin Redis latency problems troubleshooting https://redis.io/topics/latency

[Redis] warning

在redis log 發現warning: 1.WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add ‘vm.overcommit_memory = 1’ to /etc/sysctl.conf and then reboot or run the command ‘sysctl vm.overcommit_memory=1’ for this to take effect. 2.WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 3.WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command ‘echo never > /sys/kernel/mm/transparent_hugepage/enabled’ as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled. overcommit_memory: This value contains a flag that enables memory overcommitment. When this flag is 0, the kernel attempts to estimate the amount of free memory left when userspace requests more memory...

[Redis] 如何設計Redis的KEY

REDIS KEY DESIGN 現在有bankid username password balance 四種欄位 1.用Hash來設計的話,結構如以下: key field value field value … 用bankid來當key值,後面接欄位與值,故查詢時可直接用ID查KEY 接著取欄位值 一次建立多個欄位的方法為HMSET,取得特定欄位值的方法為HGET,文件有詳細說明 bankid username $username password $password balance $balance 2.用List設計的話,結構如以下: key value value … bankid $id $username $password $balance 這邊需要考慮到如果餘額是歷史交易的餘額,而不是作為最終餘額的話就可以用LIST, 不然LIST缺乏field name 更改值的同時又要保持順序不太方便, 畢竟LIST取值的時候因為沒有欄位只能靠index索引,順序打亂很麻煩, 否則就是要在value命名上動手腳來辨識。 3.用單一KEY來儲存 把bankid的每個欄位都獨立成一個KEY,結構如下: key value bankid $id bankid:username $username bankid:password $password bankid:balance $balance 以上的設計為銀行帳戶的部分, 若要再加上交易行為紀錄,命名的部分就需要多加考慮,撈資料才好撈。 交易行為分為存款與提款,匯款的部分就是雙方存款提款的組合,這邊先設計存款提款就好。 一開始一樣用bank_id來當作key,目的是為了查詢某個銀行的某幾筆交易紀錄, 例如某銀行所有交易紀錄指令就可以下 KEYS bank_id:trade_id* KEYS用來查詢符合條件的KEY, '*'代表符合前面這段的全部值 結合起來意思就是是查詢以 帳戶:交易紀錄編號 為開頭的所有KEY。 先規劃架構如下,這邊雖然麻煩點不過為了以後下指令比較明白, 將KEY以欄位冒號值的形式描述,並在開頭帶上table name。 trade:bankid:$bankid:tradeid:$tra...

[Redis] 如何同步MySQL與Redis

同步: http://blog.csdn.net/irean_lau/article/details/51395515 遷移: https://www.oschina.net/translate/mysql-to-redis-in-one-step 架構圖: https://github.com/liukelin/canal_mysql_nosql_sync 討論: https://www.zhihu.com/question/36413559

[Redis] How to use redis in symfony

Redis https://www.linode.com/docs/databases/redis/install-and-configure-redis-on-centos-7 introduce http://blog.techbridge.cc/2016/06/18/redis-introduction/ SETTING https://github.com/snc/SncRedisBundle/blob/master/Resources/doc/index.md https://www.slideshare.net/ricardclau/speed-up-your-symfony2-application-and-build-awesome-features-with-redis

[Redis] KEY 設計

http://yhhuang1966.blogspot.tw/2015/07/lua_14.html http://blog.csdn.net/irean_lau/article/details/51395515 結構圖: https://www.zhihu.com/question/36413559 https://github.com/liukelin/canal_mysql_nosql_sync http://blog.nosqlfan.com/html/3033.html https://github.com/snc/SncRedisBundle/blob/master/Resources/doc/index.md https://www.oschina.net/translate/mysql-to-redis-in-one-step https://gnuhpc.gitbooks.io/redis-all-about/CodeDesignRule/keydesign.html ... 3 75 $redis = $this->container->get('snc_redis.default');~ 3 76 $redis->SET("bank:bankid:$registerID:username","$registerUsername");~ 3 77 $redis->SET("bank:bankid:$registerID:paassword","$registerPassword");~ 3 78 $redis->SET("bank:bankid:$registerID:balance",'0');~ ... 127.0.0.1:6379> KEYS * 1) "bank:bankid:121:balance" 2) "bank:bankid:121:username" 3) "bank:bankid:121:paass...