Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Wprowadzenie do Redisa
Search
Michał Szajbe
September 17, 2014
Programming
130
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Wprowadzenie do Redisa
(In Polish)
Presented at Bydgoszcz Web Development Meetup #6
Michał Szajbe
September 17, 2014
More Decks by Michał Szajbe
See All by Michał Szajbe
Deployment kodu z Capistrano
szajbus
0
80
Other Decks in Programming
See All in Programming
[DroidKaigi 2026] Bring your own phones to Gradle Managed Devices
f2lk
0
120
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
190
Omarchy Tokyo やると聞いて UMPC 買ってセットアップしてきた
mtsmfm
0
140
個人開発基盤をまるごとCloudflareに引っ越して爆速で総合的体験を向上させた話
tinykitten
0
190
AIは賢い。でも実行環境は? CLIおじさんがAI時代に伝えたいこと ~ CLIおじさんがAI時代に伝えたいこと ~
curekoshimizu
1
240
Security issues being discussed on Web Platforms
petamoriken
0
940
What We Talk About When We Talk About XP
m_seki
2
620
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
100
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
710
スマート反転とウェブアクセシビリティ
camiha
0
210
From 6 People Classroom Meetup to 100 People Regional Conference / FOSS4G Hiroshima 2026
furukawayasuto
0
200
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
370
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
55
10k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.7k
The SEO identity crisis: Don't let AI make you average
varn
0
560
A Tale of Four Properties
chriscoyier
163
24k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
360
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
The Limits of Empathy - UXLibs8
cassininazir
1
670
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
230
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.6k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
Transcript
Michał Szajbe
Czym jest Redis? • Baza danych typu klucz-wartość# • Serwer
struktur danych# • Pozwala na atomiczne operacje na danych# • Trzyma dane w pamięci operacyjnej
key-value store • Klucz = unikalny identyfikator# • Wartość =
dane# • Analogia: hash, map, tablica asocjacyjna# • Przykład: Zbiór PESEL, książka telefoniczna
key-value store key1 value1 key2 value2 key3 value3
String • Podstawowa struktura (nie typ!) danych w Redisie# •
Może zawierać dowolne dane, np. obrazy JPEG, bitmapy, tekst, serializowane obiekty# • Max 512 MB
String name Bydgoszcz Web SET name "Bydgoszcz Web" nr 5
SET nr 5
String name Bydgoszcz Web Development Meetup APPEND name " Development
Meetup" GETRANGE name 10 24 Web Development
String nr 6.5 INCRBYFLOAT nr 0.5 nr 6 INCR nr
String bits1 1100 bits2 1010 BITOP AND result bits1 bits2
result 1000
Lista • Uporządkowana kolekcja stringów (nie tablica!)# • Możliwość dodania
elementu od prawej lub lewej strony# • Bardzo szybki dostęp do skrajnych elementów, wolniejszy do środkowych - O(N) list e1 e2 e3
Lista RPUSH speakers Artur RPUSH speakers Michał speakers Artur
Michał LPUSH speakers Bartek speakers Bartek Artur Michał
Lista LLEN speakers 3 LRANGE speakers 0 -2 Bartek Artur
RPOP speakers Michał speakers Bartek Artur
Przykład: Newsfeed • Chronologicznie# • Tylko 3 najświeższe wiadomości
Przykład: Newsfeed • Chronologicznie# • Tylko 3 najświeższe wiadomości newsfeed
Fotki J. Lawrence WordPress Coś o Tusku
Przykład: Newsfeed LPUSH newsfeed Redis ! LTRIM newsfeed 0 3
Przykład: Newsfeed LPUSH newsfeed Redis ! LTRIM newsfeed 0 3
newsfeed Redis Fotki J. Lawrence WordPress
Zbiór (Set) • Nieuporządkowana kolekcja stringów# • Szybkie dodawanie, usuwanie
i sprawdzanie istnienia elementów w zbiorze# • Tylko unikalne wartości set e1 e2 e3
Zbiór (Set) SADD bookmarks bdgweb.pl ! SADD bookmarks monterail.com !
SADD bookmarks codetunes.com bookmarks bdgweb.pl monterail.com codetunes.com
Zbiór (Set) SRANDMEMBER bookmarks codetunes.com SREM bookmarks codetunes.com SMEMBERS bookmarks
bookmarks bdgweb.pl monterail.com
Operacje na zbiorach set1 a b c set2 a x
z SUNION set1 set2 a b c x z SINTER set1 set2 a SDIFF set1 set2 b c
Operacje na zbiorach set1 a b c set2 a x
z SMOVE set1 set2 c set1 a b set2 a x z c
Hash • Mapuje stringi na wartości (też stringi)# • Dobre
do reprezentacji obiektów hash field1 value1 field2 value2
Hash HSET user name John ! HMSET user age 30
gender male user name John age 30 gender male
Hash HINCRBY user age 1 HMGET user name age John
31 HGET user age 31
Uporządkowany zbiór (Sorted Set) • Połączenie zbioru z hashem# •
Każdy element ma przypisany "score"# • Elementy są automatycznie porządkowane wg score# • Przydatne do budowania rankingów, indeksowania
Uporządkowany zbiór (Sorted Set) clicks link1 1 link2 2 link3
4
Uporządkowany zbiór (Sorted Set) ZADD clicks 1 link4 ! ZINCRBY
clicks 1 link1 clicks link4 1 link1 2 link2 2 link3 4
Uporządkowany zbiór (Sorted Set) ZRANGE clicks 0 1 link4 link1
ZREVRANGE clicks 0 1 link3 link2 ZSCORE clicks link3 4
Uporządkowany zbiór (Sorted Set) ZRANGEBYSCORE clicks 2 +inf WITHSCORES link1
2 link2 2 link3 4
Wygaszanie kluczy e87Yc0iK SET token e87Tc0iK ! EXPIRE token 5
! GET token ! ! ! GET token (nil) po upływie 5 sekund...
Inne ficzery • Transakcje (poprzez kolejkowanie poleceń)# • Pub/sub# •
Skryptowanie (w języku Lua)# • Sharding i replikacja
Przydatne linki • redis.io# • try.redis-db.com