- Overview delle strutture dati.
- Persistenza: fork() e copy on write.
- Implementazione di EXPIRE con sampling a approssimazione dell'algoritmo LRU.
- Indici secondari usando i sorted set (inclusi i comandi LEX).
- Geoindexing rappresentato da sorted set.
- Mass import di dati tramite redis-cli.
- Protocollo REPL.
- Lua scripting.
- Implementazione low level delle strutture dati: 1) Implementazione dual-ported dei sorted set (hash table + skiplist). 2) Hash table con rehashing incementale. 3) Quicklists: ovvero le liste di Redis sono implementate come delle liste linkate di mega-blob che contengono N oggetti.
- Maxmemory e policy di eviction al raggiungimento della memoria. LRU e LFU.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head><title>Fizzlefade</title></head> | |
<body> | |
<canvas id="framebuffer" width="320" height="200"></canvas> | |
<script type="text/javascript"> | |
/* Fizzlefade using a Feistel network. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36143:M 27 Jun 11:18:39.096 # Server initialized | |
36143:M 27 Jun 11:18:39.096 # Internal error in RDB reading function at rdb.c:1378 -> Unknown RDB encoding type 7 | |
[offset 0] Checking RDB file dump.rdb | |
[offset 32] AUX FIELD redis-ver = '999.999.999' | |
[offset 46] AUX FIELD redis-bits = '64' | |
[offset 58] AUX FIELD ctime = '1498554991' | |
[offset 73] AUX FIELD used-mem = '1014768' | |
[offset 89] AUX FIELD aof-preamble = '0' | |
[offset 139] AUX FIELD repl-id = 'f7a20a009964381cdcc61f401f91f9b228801647' | |
[offset 154] AUX FIELD repl-offset = '0' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127.0.0.1:6379> client setname worker-502 | |
OK | |
127.0.0.1:6379> debug sleep 1 | |
OK | |
(1.00s) | |
127.0.0.1:6379> slowlog get | |
1) 1) (integer) 0 | |
2) (integer) 1497523890 | |
3) (integer) 1002448 | |
4) 1) "debug" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <pthread.h> | |
#include <stdio.h> | |
volatile uint64_t x = 0; | |
void *writeThread(void *arg) { | |
for (uint64_t i = 0; i < 10000000; i++) { | |
while(!__sync_bool_compare_and_swap(&x,x,i+(i<<32))); // x = i+(i<<32) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* The thread entry point that actually executes the blocking part | |
* of the command HELLO.KEYS. | |
* | |
* Note: this implementation is very simple on purpose, so no duplicated | |
* keys (returned by SCAN) are filtered. However adding such a functionality | |
* would be trivial just using any data structure implementing a dictionary | |
* in order to filter the duplicated items. */ | |
void *HelloKeys_ThreadMain(void *arg) { | |
RedisModuleBlockedClient *bc = arg; | |
RedisModuleCtx *ctx = RedisModule_GetThreadSafeContext(bc); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# LVDB - LLOOGG Memory DB | |
# Copyriht (C) 2009 Salvatore Sanfilippo <[email protected]> | |
# All Rights Reserved | |
# TODO | |
# - cron with cleanup of timedout clients, automatic dump | |
# - the dump should use array startsearch to write it line by line | |
# and may just use gets to read element by element and load the whole state. | |
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands. | |
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void somefunc(rax *mytree) { | |
raxIterator iter; | |
raxStart(&iter,mytree); | |
/* As seek operator you can use >, <, >=, <=, == */ | |
raxSeek(&iter,(unsigned char*)"chromo",6,"<="); /* Seek key <= "chromo" */ | |
while(raxNext(&iter,NULL,0,NULL)) { /* or raxPrev() */ | |
printf("Current key: %.*s, val %p\n", | |
(int)iter.key_len, (char*)iter.key, iter.data); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* MacOS libc PRNG is garbage! | |
* Test this on MacOS 10.12.3 (may be the same with other versions) | |
* You'll see three times the same output. | |
* Cheers by @antirez. */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
int main(void) { | |
/* Note, 1000000, 1000001, 1000002 are not special. |
Radix tree ASCII printing.
[r] -> [ou]
`-(o) [m] -> [au]
`-(a) [n] -> [eu]
`-(e) []=0x0
`-(u) [s] -> []=0x1
`-(u) "lus" -> []=0x2
`-(u) [b] -> [ei]