Redis – Hash – tablice asocjacyjne – obiekty płaskie (JS)

HSET, HGET, HGETALL, HEXISTS, HDEL

> HSET profil.1 name Frank      - kropka traktowana jest jak każdy inny znak
> HSET profil.1 login johnny

Odpowiednik obj w Javascript

{ "profil.1" : { "name" : "Frank", "login" : "johnny", ... } }
127.0.0.1:6379> HGET profil.1 login
"john"

127.0.0.1:6379> HGETALL profil.1
1) "name"
2) "Frank"
3) "login"
4) "john"
127.0.0.1:6379> HEXISTS profil.1 name
(integer) 1
127.0.0.1:6379> HEXISTS profil.1 age   - klucz nie istnieje
(integer) 0
127.0.0.1:6379> HDEL profil.1 login
(integer) 1
127.0.0.1:6379> HDEL profil.1 login   - już nie istnieje
(integer) 0

Help

127.0.0.1:6379> help @hash

HDEL key field [field ...]
Delete one or more hash fields

HEXISTS key field
Determine if a hash field exists

HGET key field
Get the value of a hash field

HGETALL key
Get all the fields and values in a hash

HINCRBY key field increment
Increment the integer value of a hash field by the given number

HINCRBYFLOAT key field increment
Increment the float value of a hash field by the given amount

HKEYS key
Get all the fields in a hash

HLEN key
Get the number of fields in a hash

HMGET key field [field ...]
Get the values of all the given hash fields

HMSET key field value [field value ...]
Set multiple hash fields to multiple values

HSCAN key cursor [MATCH pattern] [COUNT count]
Incrementally iterate hash fields and associated values

HSET key field value
Set the string value of a hash field

HSETNX key field value
Set the value of a hash field, only if the field does not exist

HSTRLEN key field
Get the length of the value of a hash field

HVALS key
Get all the values in a hash