如果使用排序集,列表和散列,則沒有具體含義。
您可以將您的UUID爲字符串,如:
110E8400-E29B-11D4-A716-446655440000
在這種情況下,它會採取每38個值字節。如果您不關心存儲人類可讀的值,您可能更願意利用Redis能力來存儲二進制數據(對於鍵和值),並將uuids僅存儲爲16字節。
您的短名單,排序集和散列將按照Redis文檔中的說明序列化。您可能需要調整下面的參數來調整Redis的行爲和你的工作量:
# Hashes are encoded using a memory efficient data structure when they have a
# small number of entries, and the biggest entry does not exceed a given
# threshold. These thresholds can be configured using the following directives.
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
# Similarly to hashes, small lists are also encoded in a special way in order
# to save a lot of space. The special representation is only used when
# you are under the following limits:
list-max-ziplist-entries 512
list-max-ziplist-value 64
# Sets have a special encoding in just one case: when a set is composed
# of just strings that happens to be integers in radix 10 in the range
# of 64 bit signed integers.
# The following configuration setting sets the limit in the size of the
# set in order to use this special memory saving encoding.
set-max-intset-entries 512
# Similarly to hashes and lists, sorted sets are also specially encoded in
# order to save a lot of space. This encoding is only used when the length and
# elements of a sorted set are below the following limits:
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
現在,如果你打算使用臺(套簡,沒有排序套),有一個名爲INTSET,你將一個具體的優化如果您使用UUID作爲密鑰,則不會從中受益。 intset只能用於編碼64位數字,所以16個字節的UUID不適合。如果您打算存儲大量集合,那麼添加間接方式可能會有好處,並將整數用作主鍵而不是UUID。否則它是毫無意義的。
謝謝迪迪埃。從redis文檔(http://redis.io/commands/object) - 「集合可以編碼爲intset或散列表,intset是一種特殊的編碼,用於**小**集合,僅由整數組成」 - 你對「小」意味着什麼有一個概念? – papdel
「small」由set-max-intset-entries參數定義。使用默認配置時,少於512個項目組被認爲是小的,因此將被存儲爲intsets。 –
重要的是要注意,只有集合中的元素需要64位整數才能適合緊湊集合。集合本身的主鍵可以是任何東西,包括UUID的字節或字符串表示。 –