最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

redis key 命名規(guī)范 鍵名稱中的冒號 : 命名空間層次的表示

2022-11-18 22:43 作者:萬事俱備就差個(gè)程序員  | 我要投稿


數(shù)據(jù)庫

46 篇文章0 訂閱

訂閱專欄

結(jié)論

redis中key的命名,用:分隔不同的層次|命名空間,如:user:id12345:contact

如果某個(gè)對象有字段的字段,用.連接。如user:id12345:contact.mail。


以及一款redis的可視化操作工具:Redis Desktop Manager。


Links

redis官網(wǎng)文檔:https://redis.io/topics/data-types-intro

SO社區(qū)問答:https://stackoverflow.com/questions/6965451/redis-key-naming-conventions

國內(nèi)社區(qū)問答:https://answer-id.com/51740587


原文:


Very short keys are often not a good idea. There is little point in writing "u1000flw" as a key if you can instead write "user:1000:followers". The latter is more readable and the added space is minor compared to the space used by the key object itself and the value object. While short keys will obviously consume a bit less memory, your job is to find the right balance.

Try to stick with a schema. For instance "object-type:id" is a good idea, as in "user:1000". Dots or dashes are often used for multi-word fields, as in "comment:qq12345:reply.to" or "comment:qq12345:reply-to".

1

2

即下圖中的第2、3點(diǎn):



其他分隔符

讀過文首三個(gè)鏈接會發(fā)現(xiàn)以下格式的ID:

user:id12345:contact 表示user表的ID為id12345的記錄的字段contact。(那這個(gè)key的值就是對應(yīng)的字段的值了)

user::id12345::contact或user:::id12345:::contact,即多層冒號分隔。

user/id12345/contact

使用多層冒號分隔、使用/分隔,我測試過后,都可以正常獲取key的值。但是:

在RedisDesktopManager這款Redis可視化管理工具中,只有使用單個(gè):分隔的key名稱,層次看起來最舒服【圖不貼了,有興趣自己試試看】。

另外redis官網(wǎng)也是介紹的:,所以key名稱的層次分隔符就推薦單個(gè)冒號:


最后一個(gè)字段contact,如果聯(lián)系方式包含三種:tel, mail, qq,怎么命名?

官網(wǎng)說可以使用.或-連接,如:user:id12345:contact.mail或user.id12345.contact-mail表示用戶表中ID為id12345的記錄的contact屬性中的mail屬性值。

————————————————

版權(quán)聲明:本文為CSDN博主「錦天」的原創(chuàng)文章,遵循CC 4.0 BY-SA版權(quán)協(xié)議,轉(zhuǎn)載請附上原文出處鏈接及本聲明。

原文鏈接:https://blog.csdn.net/wuyujin1997/article/details/106267676/


redis key 命名規(guī)范 鍵名稱中的冒號 : 命名空間層次的表示的評論 (共 條)

分享到微博請遵守國家法律
抚顺县| 九台市| 宜昌市| 惠水县| 富锦市| 菏泽市| 蓝田县| 四川省| 日喀则市| 察隅县| 石棉县| 芦山县| 汽车| 天津市| 庆元县| 阿克| 南漳县| 资兴市| 宁蒗| 邓州市| 库尔勒市| 德化县| 垦利县| 沽源县| 星座| 甘孜县| 泰宁县| 班玛县| 虞城县| 桂阳县| 田阳县| 工布江达县| 湾仔区| 毕节市| 乌兰浩特市| 安国市| 新余市| 洞头县| 教育| 金寨县| 喀喇|