-
dbDictType used as argument to dictCreate in server.c (initServer)
-
Uses dictSdsHash, dictSdsKeyCompare, dictSdsKeyDestructor, dictObjectDestructor
-
dict struct:
- dictType
- privdata
- ht (2 of them)
- rehashidx
- iterators
-
dictht:
- table (dictentry)
- size
- sizemask
- used
-
dictentry:
- key
- v (val, u64, s64, d)
- next
-
dictAdd
- calls dictAddRaw
- calls dictSetVal (a macro, sets the val to the entry)
-
dictAddRaw (dict.c)
- get the index with _dictKeyIndex and dictHashKey(d, key)
- prepends the entry to ht->table with the index from the previous step, itself is a list of entries
- calls dictSetKey (a macro, sets the key to entry)
-
setGenericCommand (takes the key as argument, and the val)
- called from ...
-
genericSetKey (db.c)
- calls dbAdd
-
dbAdd (db.c)
- calls dictAdd (dict.c)
-
dictAdd (above)
-
tryResizeHashTables is called from databasesCron
- itself called from serverCron
-
Two similar functions dictResize & dictExpand. Resize calls Expand
- expand does the actual expand
- resize figures out the size for you
- Rehash Just sets up the second ht for rehashing (->rehashidx = 0)
-
incrementallyRehash is called in databsesCron (server.c)
- aaa
-
rules for _dictExpandIfNeeded (called for every call to _dictKeyIndex)
- Resize to 2x the size if used >= size && (can_resize || used/size > 5)
- Resize will find the right size, so it might shrink it
- Will resize if bigger than 4 but usage is below 10%
-
dictHashKey is a macro (dict.h)
- delegates to (d)->type->hashFunction (dictSdsHash here)
-
dictSdsHash (in server.c)
- calls dictGenHashFunction (in dict.c)
-
dictGenHashFunction
- calls siphash
-
dictSetHashFunctionSeed
- called in main (server.c) with hashseed, result of getRandomBytes
-
_dictKeyIndex (in dict.c)
Created
August 27, 2020 18:46
-
-
Save pjambet/349882dcaa523cc8638829c9e95d38e6 to your computer and use it in GitHub Desktop.
Notes about Redis
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment