Use hash of key as priority. Vendor xxhash v0.8.2

This commit is contained in:
2024-05-01 14:17:26 -07:00
parent 72cb7a70bf
commit 11e6278766
5 changed files with 6825 additions and 3 deletions

View File

@@ -7,6 +7,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <unordered_set>
#include <xxhash.h>
void *mmapSafe(void *addr, size_t len, int prot, int flags, int fd,
off_t offset) {
@@ -86,7 +87,7 @@ struct Entry {
e->keyLen = keyLen;
e->valLen = valLen;
e->refCount = 1;
e->priority = rand(); // TODO
e->priority = XXH3_64bits(key, keyLen);
e->clearTo = clearTo;
memcpy((uint8_t *)e->getKey(), key, keyLen);
((uint8_t *)e->getKey())[keyLen] = 0;