Redis - REmote DIctionary Server

Thursday, 12 February 09
Per ora sto lavorando finalmente, nuovamente, ad un progetto che ho in mente da piu' di un anno. Avete presente memcached? Immaginatelo persistente, e con funzioni piu' avanzate secondo me irrinunciabili per non avere solo una semplice cache ma una alternativa ai database relazionali.

Il tutto sara' rilasciato sotto una licenza BSD. E' da qualche settimana che ci ho rimesso le mani e sono vicino ad avere un prototipo funzionante. Mentre Fabio sta scrivendo una lib per accedere al server via PHP. E' il momento giusto per rivere feedbacks, per cui posto di seguito parte del README che fa capire come funziona il database e cosa offre di preciso. Grazie per qualunque feedback.

Redis non ha alcuna dipendenza, e' scritto in C, e richiede un sistema POSIX per girare.

REDIS - REmote DIctionary Server

============= WHAT'S REDIS? =============

Redis is a database. To be more specific redis is a very simple database implementing a dictionary where keys are associated with values. For example I can set the key "surname_1992" to the string "Smith".

Redis takes the whole dataset in memory, but the dataset is persistent since from time to time it writes a dump of the dataset on disk. The dump is loaded every time the server is restarted.

This means that it can happens that after a system crash the last modifications of the dataset are lost, but it's the price to pay for a lot of speed. Redis is the right database for all the applications where it is acceptable after a crash that some modification gets lost, but where speed is very important.

However you can configure Redis to save the DB after a given number of modifications and/or after a given amount of time since the last change in the dataset. Saving happens in background so the DB will continue to server queries while it is saving the DB dump on disk.

================================= HOW REDIS DIFFERS FROM MEMCACHED? =================================

Maily in two ways:

- Memcached is not persistent, it just holds everything in memory without saving since its main goal is to be uesd as a cache. Redis instead can be used as the main DB for the application. - Like memcached Redis uses a key-value model, but while keys can just be strings, values in Redis can be lists and sets, and complex operations like intersections and concatenations can be performed against sets and lists.

================ REDIS DATA TYPES ================

Redis support the following three data types as values:

- Strings: just any sequence of bytes. Redis strings are binary safe so they can not just hold text, but images, copressed data and everything else. - Lists: lists of strings, with support for operations like append a new string on head, on tail, list length, obtain a range of elements, truncate the list to a given length, sort the list, and so on. - Sets: an unsorted set of strings. It is possible to add or delete elements from a set, to perform set intersection, union, subtraction, and so on.

Values can be Strings, Lists or Sets. Keys can be a subset of strings not containing newlines ("\n") and spaces (" ").

Implementation details ----------------------

Strings are implemented as dynamically allocated strings of characters. Lists are implemented as doubly liked lists with cached length. Sets are implemented using hash tables that use chaining to resolve collisions.
post letto 7330 volte (1.3 letture al giorno in media)
Postato alle 11:32:13 permalink | 16 commenti | stampa | posta | trackbacks