SlideShare a Scribd company logo
1 of 58
Download to read offline
Garry Shutler | @gshutler
Garry Shutler | @gshutler
@gshutler
What is it?
@gshutler
@gshutler
What is it good for?
@gshutler
The Redis protocol
Simple to implement
Fast to parse
Human readable
@gshutler
@gshutler
The Redis protocol
COMMAND KEY ARGS...
@gshutler
@gshutler
The Redis protocol
redis.command(key, *args)
@gshutler
@gshutler
The Redis protocol
SET mykey 3
@gshutler
@gshutler
The Redis protocol
redis.set("mykey", 3)
@gshutler
@gshutler
The Redis protocol
SET mykey 3 EX 3600
@gshutler
@gshutler
The Redis protocol
redis.set("mykey", 3, { "ex": 3600 })
@gshutler
@gshutler
Cache
@gshutler
Cache
function cached(key, fn) {
var value = redis.get(key);
if (!value) {
value = fn();
redis.set(key, value);
}
return value;
}
@gshutler
Cache
function expensiveThing() {
return cached("expensive", function () {
// do something that's expensive
return expensiveValue;
});
}
@gshutler
Cache
expensiveThing(); // miss
expensiveThing(); // hit
expensiveThing(); // hit
@gshutler
Cache
function expensiveThing(param) {
var key = "expensive:" + param;
return cached(key, function () {
sleep(param);
return param;
});
}
@gshutler
Cache
expensiveThing(1); // miss
expensiveThing(1); // hit
expensiveThing(2); // miss
expensiveThing(2); // hit
expensiveThing(1); // hit
@gshutler
Cache
function cached(key, expiry, fn) {
var value = redis.get(key);
if (value) {
redis.expire(key, expiry);
} else {
value = fn();
redis.set(key, value, { "ex": expiry });
}
return value;
}
@gshutler
Cache
function expensiveThing(param) {
var key = "expensive:" + param;
return cached(key, 3600, function () {
sleep(param);
return param;
});
}
@gshutler
or
vs
Relative
In 5 minutes
Absolute
At 9am
@gshutler
Expiration
@gshutler
Expiration
my_report:last_hour
@gshutler
@gshutler
Expiration
my_report:2015051118
@gshutler
@gshutler
Data types
@gshutler
@gshutler
String
@gshutler
@gshutler
List
@gshutler
@gshutler
Set
@gshutler
@gshutler
Conditional GET
@gshutler
@gshutler
Conditional GET
var etagKey = "etag:" + url;
if (storedEtag = redis.get(etagKey)) {
headers["If-None-Match"] = storedEtag;
}
var response = http.get(url, headers);
var etag = response.headers["ETag"];
redis.set(etagKey, etag, { "ex": 300 });
@gshutler
@gshutler
Touch values
@gshutler
@gshutler
Touch values
SET {KEY} 1 EX {TIME}
EXISTS {KEY}
@gshutler
@gshutler
Ephemeral lookups
@gshutler
@gshutler
Ephemeral lookups
Forgotten password IDs
OAuth access tokens
Voucher codes
@gshutler
@gshutler
Time-series counter
@gshutler
@gshutler
Time-series counter
INCR clicks:201505111830
@gshutler
@gshutler
Time-series counter
INCR clicks:201505111830
INCR clicks:2015051118
INCR clicks:20150511
@gshutler
@gshutler
Time-series counter
INCR clicks:201505111830
EXPIRE clicks:201505111830 86400
INCR clicks:2015051118
EXPIRE clicks:2015051118 2419200
INCR clicks:20150511
@gshutler
@gshutler
Time-series counter
> MGET clicks:201505111826
clicks:201505111827
clicks:201505111828
clicks:201505111829
clicks:201505111830
1)"5"
2)(nil)
3)"2"
4)"10"
5)"1"
@gshutler
@gshutler
Unique visitors
@gshutler
@gshutler
Unique visitors
SADD {KEY} {VALUE}
@gshutler
@gshutler
Unique visitors
SADD visitors:2015051118 1
SADD visitors:2015051118 2
SADD visitors:2015051118 2
@gshutler
@gshutler
Unique visitors
SCARD {KEY}
@gshutler
@gshutler
Unique visitors
SCARD visitors:2015051118
@gshutler
@gshutler
Queuing
@gshutler
@gshutler
Queuing
RPUSH {KEY} {VALUE}
@gshutler
@gshutler
Queuing
RPUSH queue 1
RPUSH queue 2
@gshutler
@gshutler
Queuing
["1", "2"]
@gshutler
@gshutler
Queuing
LPOP {KEY}
@gshutler
@gshutler
Queuing
LPOP queue
@gshutler
@gshutler
Queuing
"1"
@gshutler
@gshutler
Queuing
["2"]
@gshutler
@gshutler
Queuing
LPUSH queue 3
@gshutler
@gshutler
Queuing
["3", "2"]
@gshutler
@gshutler
Queuing
@gshutler
RPUSH queue 4 RPUSH queue 5
queue
LPOP queue LPOP queue LPOP queue
@gshutler
Queuing
BLPOP {KEY}... {TIMEOUT}
@gshutler
@gshutler
Queuing
Encoded values
Reply queues
@gshutler
@gshutler
Have a go
@gshutler
@gshutler
Have a go
Cached Fibonacci
Distributed processing
@gshutler
Garry Shutler | @gshutler

More Related Content

Viewers also liked

License system-foss-oer-present
License system-foss-oer-presentLicense system-foss-oer-present
License system-foss-oer-presentnghia le trung
 
Prezentacija privredne komore alzasa
Prezentacija privredne komore alzasaPrezentacija privredne komore alzasa
Prezentacija privredne komore alzasaREFLESS Project
 
University of Southampton
University of SouthamptonUniversity of Southampton
University of SouthamptonREFLESS Project
 
šAuklių ir šatraminių kaimų
šAuklių ir šatraminių kaimųšAuklių ir šatraminių kaimų
šAuklių ir šatraminių kaimųJūratė Žiobienė
 
Uitdagingen van Basel III door prof. Jan Annaert
Uitdagingen van Basel III door  prof. Jan AnnaertUitdagingen van Basel III door  prof. Jan Annaert
Uitdagingen van Basel III door prof. Jan Annaertgeertcleuren
 
Produced by convert-jpg-to-pdf.net (1)
Produced by convert-jpg-to-pdf.net (1)Produced by convert-jpg-to-pdf.net (1)
Produced by convert-jpg-to-pdf.net (1)joelharvey
 
Soton centre for applied language research
Soton   centre for applied language researchSoton   centre for applied language research
Soton centre for applied language researchREFLESS Project
 
Info sec foss-mandate-migration-nov-2013-
Info sec foss-mandate-migration-nov-2013-Info sec foss-mandate-migration-nov-2013-
Info sec foss-mandate-migration-nov-2013-nghia le trung
 
REFLESS project partners: Comenius University in Bratislava
REFLESS project partners: Comenius University in BratislavaREFLESS project partners: Comenius University in Bratislava
REFLESS project partners: Comenius University in BratislavaREFLESS Project
 
REFLESS project top-level conference: Waldemar Martyniuk, Council of Europe's...
REFLESS project top-level conference: Waldemar Martyniuk, Council of Europe's...REFLESS project top-level conference: Waldemar Martyniuk, Council of Europe's...
REFLESS project top-level conference: Waldemar Martyniuk, Council of Europe's...REFLESS Project
 
Presentation Resume (Marissa Dodd)
Presentation Resume (Marissa Dodd)Presentation Resume (Marissa Dodd)
Presentation Resume (Marissa Dodd)Marissa Dodd
 
Buiding foss-community-oct-2014
Buiding foss-community-oct-2014Buiding foss-community-oct-2014
Buiding foss-community-oct-2014nghia le trung
 

Viewers also liked (20)

Mo hinhbenvung foss
Mo hinhbenvung fossMo hinhbenvung foss
Mo hinhbenvung foss
 
License system-foss-oer-present
License system-foss-oer-presentLicense system-foss-oer-present
License system-foss-oer-present
 
FossStartUp-mar-2016
FossStartUp-mar-2016FossStartUp-mar-2016
FossStartUp-mar-2016
 
Prezentacija privredne komore alzasa
Prezentacija privredne komore alzasaPrezentacija privredne komore alzasa
Prezentacija privredne komore alzasa
 
University of Southampton
University of SouthamptonUniversity of Southampton
University of Southampton
 
как это работает
как это работаеткак это работает
как это работает
 
šAuklių ir šatraminių kaimų
šAuklių ir šatraminių kaimųšAuklių ir šatraminių kaimų
šAuklių ir šatraminių kaimų
 
Uitdagingen van Basel III door prof. Jan Annaert
Uitdagingen van Basel III door  prof. Jan AnnaertUitdagingen van Basel III door  prof. Jan Annaert
Uitdagingen van Basel III door prof. Jan Annaert
 
Produced by convert-jpg-to-pdf.net (1)
Produced by convert-jpg-to-pdf.net (1)Produced by convert-jpg-to-pdf.net (1)
Produced by convert-jpg-to-pdf.net (1)
 
Info sec nov-2014
Info sec nov-2014Info sec nov-2014
Info sec nov-2014
 
Soton centre for applied language research
Soton   centre for applied language researchSoton   centre for applied language research
Soton centre for applied language research
 
Past continuous
Past continuousPast continuous
Past continuous
 
Info sec foss-mandate-migration-nov-2013-
Info sec foss-mandate-migration-nov-2013-Info sec foss-mandate-migration-nov-2013-
Info sec foss-mandate-migration-nov-2013-
 
REFLESS project partners: Comenius University in Bratislava
REFLESS project partners: Comenius University in BratislavaREFLESS project partners: Comenius University in Bratislava
REFLESS project partners: Comenius University in Bratislava
 
WEB
WEB WEB
WEB
 
REFLESS project top-level conference: Waldemar Martyniuk, Council of Europe's...
REFLESS project top-level conference: Waldemar Martyniuk, Council of Europe's...REFLESS project top-level conference: Waldemar Martyniuk, Council of Europe's...
REFLESS project top-level conference: Waldemar Martyniuk, Council of Europe's...
 
Presentation Resume (Marissa Dodd)
Presentation Resume (Marissa Dodd)Presentation Resume (Marissa Dodd)
Presentation Resume (Marissa Dodd)
 
De Punta a Punta
De Punta a PuntaDe Punta a Punta
De Punta a Punta
 
Could (not)
Could (not)Could (not)
Could (not)
 
Buiding foss-community-oct-2014
Buiding foss-community-oct-2014Buiding foss-community-oct-2014
Buiding foss-community-oct-2014
 

Recently uploaded

CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 

Recently uploaded (20)

CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 

Redis is the answer, what's the question - Tech Nottingham

Editor's Notes

  1. REmote DIctionary Server Shared variables on the network Shared memory isn’t always bad Dealing with locks is hard, Redis does that for you Atomic operations through a single thread, fast as hell
  2. Caching and queues are regular use cases but it’s capable of much more Relevant now more than ever as microservices/SOA gains in popularity, distributed processes need ways to co-ordinate This can be done via your regular SQL database but it is churn-heavy Added load to the database is bad Store intermediary results elsewhere You will end up implementing many of Redis’ features Much better to isolate it into a separate process/service Also much superior to having an in-memory cache per machine as values only need to be cached once for the whole system, not once per server/process
  3. Going to
  4. Redis is a key-value store at heart Key can have an expiry set Value can be one of many types
  5. cached function hasn't need to change Key has to vary with parameters, namespacing is common
  6. Problem with this is it can grow infinitely, need to think about expiring data
  7. Expiry LRU cache
  8. Always set one when possible Relative is useful for "rolling windows" as demonstrated or caching "good enough" results Absolute useful for "valid until" things such as hourly or daily reports Rarely use absolute, instead build the time period into the key and set a relative expiry
  9. Namespacing of keys (again) Small overhead but good for your sanity Named keys are the exception, better to be absolute
  10. Allows for composite reports much more easily Implicitly moves last_hour forward at the boundary Can set expiry for the current hour differently in code For example current hour cache for 1 minute, past hour cache for 1 month
  11. Base value type is a string Keys are always a string Only going to cover the core ones, there's a few more specialised data types
  12. The most simple case Both the key and the value are a string Can be treated like an integer in some case which we'll cover, highly optimised operations
  13. The value is a list of strings Useful where order is important, building block for queue structures
  14. The value is a unique set of strings Useful where uniqueness is important, for example click tracking
  15. Similar to a raw cache, but about avoiding work rather than knowing work Can improve the performance High-churn so not well suited to a database If value lost not end of world
  16. Conditional GET is special case of "touch"
  17. Value doesn't really matter, the presence of key is what matters Something has been done recently or is being done so don't duplicate work Distributed locks are a special case of this, basic is usually sufficient
  18. Often need short-lived values
  19. Password Value contains user ID Expiry set to make link invalid Delete key on use to make single-use Access tokens Value contains details to look up full authorization Also expire after a time, use refresh token to get a new one Voucher codes Similar to password Could store JSON as value for more complex relationships
  20. No concept of storing an integer, but has specialised methods for treating them as such
  21. More efficient when it comes to looking things up
  22. Granularity matters for different periods of time 24 hours for minute-level 4 weeks for hour-level Forever for day level Pipelining Saves multiple round trips, perfect in this case
  23. MGET - multiple GET GET for a non-existent key (in our case never called INCR) returns nil Trivial to map this to a single int in code MGET essentially is inlined GETs so effectively unlimited, danger of multiple O(1) operations hence another reason to split to sensible granularity to reduce size of array Building block of a rate limiter, though you would probably expire more aggressively
  24. Along a similar line to the time-series counter, but with uniqueness Perfect for a Set S prefix to commands
  25. SADD deals with uniqueness on our behalf
  26. SCARD - set cardinality (count)
  27. Pipelining could be used to get multiple SCARDs like MGET MGETs just a more common case so has a special command
  28. Lists Key is name of list, value is a string
  29. Returns nil if list empty
  30. Returns nil if list empty
  31. Prioritisation
  32. More efficient to wait for work Should always have a timeout (seconds) Can know the process is alive if nothing else
  33. JSON Can expire complex data structures too
  34. Cached Fibonacci Distributed processing - workers could simple print - Could send an email or text message Possibly respond to sending process via response queue