Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Redis - pre info

Avatar for flenczewski flenczewski
February 15, 2015

Redis - pre info

Avatar for flenczewski

flenczewski

February 15, 2015

Other Decks in Technology

Transcript

  1. REDIS ...TO TAKI MYSQL ...ale szybszy, znacznie szybszy... CREATE TABLE

    redis ( key VARCHAR(512MB) NOT NULL, value VARCHAR(512MB), PRIMARY key (key) );
  2. REDIS ...TO TAKI MYSQL INSERT INTO redis VALUES('user:1:name', 'Seba'); SET

    "user:1:name" "Seba" SELECT * FROM redis WHERE key = 'user:1:name'; GET "user:1:name"
  3. REDIS ...TO TAKI MEMCACHED Szybka pamięciowa "baza" typu klucz =>

    wartość SET, GET, TTL ...nieco wolniejszy, ale dający "pewność" danych
  4. REDIS ...TO RÓWNIEŻ 5 typów danych (strings, hashes, lists, sets,

    sorted sets) Zapisywanie danych na dysku (w tle) Transakcje Pub/Sub Pipelining Wartość klucza do 512MB ...i dużo, dużo więcej
  5. REDIS Strings - to takie stringi w PHP Lists -

    to takie tablice w PHP (duplikaty są dozwolone) Sets - to takie tablice w PHP (duplikaty nie są dozwolone) Sorted sets - to takie tablice w PHP (...ale posortowane) Hashes - to takie "obiekty" w PHP (...albo tablice asocjacyjne)
  6. REDIS - OBSŁUGA KLUCZY... KEYS pattern // Find all keys

    matching the given pattern DEL key [key ...] // Delete a key EXPIRE key seconds // Set a key's time to live in seconds EXPIREAT key timestamp // Set the expiration for a key as a UNIX timestamp PEXPIRE key milliseconds // Set a key's time to live in milliseconds PERSIST key // Remove the expiration from a key TTL key // Get the time to live for a key PTTL key // Get the time to live for a key in milliseconds TYPE key // Determine the type stored at key MOVE key db // Move a key to another database RANDOMKEY // Return a random key from the keyspace SORT key [BY pattern] [LIMIT offset count] [GET pattern] // Sort the elements in a l
  7. REDIS - OBSŁUGA "STRINGÓW" SET key value [EX seconds] [PX

    milliseconds] [NX|XX] // Set the string value of a ke GET key // GET key GETSET key value // Set the string value of a key and return its old value MGET key [key ...] // Get the values of all the given keys MSET key value [key value ...] // Set multiple keys to multiple values SETEX key seconds value // Set the value and expiration of a key SETNX key value // Set the value of a key, only if the key does not exist INCR key, INCRBY key, INCRBYFLOAT key increment DECR key, DECRBY key STRLEN key // Get the length of the value stored in a key APPEND key value // Append a value to a key
  8. REDIS - PRZYPADKI UŻYCIA Cache Liczniki Limitatory Ostatnio widziane Logi

    Push / Powiadomienia Lista znajomych online Wyszukiwanie po kluczach Systemy kolejkowe Sesje Oceny, Statystyki Suggest Geo Search