Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should redis key be unique across different datatypes?

I am new to Redis. I am having a redis set and hset. Can I use same key for set and hset? Documents say key should be unique. Is it necessary to be unique per datatype or unique per server?

like image 242
Skanda Avatar asked Apr 07 '15 03:04

Skanda


People also ask

Are Redis keys unique?

Redis is an open-source, in-memory key-value data store. A key-value data store is a type of NoSQL database in which keys serve as unique identifiers for their associated values. Any given Redis instance includes a number of databases, each of which can hold many different keys of a variety of data types.

Is Redis key-value pair?

Basic Operations As a dictionary, Redis allows you to set and retrieve pairs of keys and values. Think of a “key” as a unique identifier (string, integer, etc.) and a “value” as whatever data you want to associate with that key. Values can be strings, integers, floats, booleans, binary, lists, arrays, dates, and more.

Are Redis keys always strings?

Keys in Redis are all strings, so it doesn't really matter what kind of value you pass into a client. Under-the-hood the RESP protocol is used and it will pass the value as a string to the engine. some_key is always a string, even if you pass 3 as key, it is handled as a string. This is true for every client.

What is the recommended size for Redis keys?

The maximum allowed key size is 512 MB.


1 Answers

Yes - it is necessary that key names be unique as each key can store one and only one basic data structure - String, Hash, List, Set or a Sorted Set (the underlying type of Bitmaps and HLLs is a String).

like image 160
Itamar Haber Avatar answered Sep 18 '22 01:09

Itamar Haber