{"id":16771503,"url":"https://github.com/jorgemarcial/workshop-redis","last_synced_at":"2025-07-30T00:36:37.118Z","repository":{"id":51492807,"uuid":"268479519","full_name":"jorgemarcial/workshop-redis","owner":"jorgemarcial","description":"workshop redis","archived":false,"fork":false,"pushed_at":"2021-05-11T16:22:24.000Z","size":185,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T16:19:29.309Z","etag":null,"topics":["example","redis","workshop"],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jorgemarcial.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-01T09:31:41.000Z","updated_at":"2020-06-04T15:26:38.000Z","dependencies_parsed_at":"2022-08-21T11:40:17.007Z","dependency_job_id":null,"html_url":"https://github.com/jorgemarcial/workshop-redis","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jorgemarcial/workshop-redis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorgemarcial%2Fworkshop-redis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorgemarcial%2Fworkshop-redis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorgemarcial%2Fworkshop-redis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorgemarcial%2Fworkshop-redis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jorgemarcial","download_url":"https://codeload.github.com/jorgemarcial/workshop-redis/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorgemarcial%2Fworkshop-redis/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267785895,"owners_count":24144124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["example","redis","workshop"],"created_at":"2024-10-13T06:28:16.691Z","updated_at":"2025-07-30T00:36:37.084Z","avatar_url":"https://github.com/jorgemarcial.png","language":"Lua","readme":"# What is redis?\n\n* In-memory data structure store, used as a database, cache and message broker.\n* Key / value database.\n* Different levels of on-disk persistence.\n\n![alt text](images/redis-usage.png)\n\n# Why redis?\n\n* Not just a cache.\n* Multiple datatypes.\n* Pub-sub model.\n* Cluster mode for high availability.\n* Perfectly works in cloud: AWS Elasticache, Azure Redis Cache and Memorystore (Google Cloud).\n\n![alt text](images/why-redis.png)\n\n![alt text](images/topredisuses.png)\n\n# Data types\n\nRemember you need in our local:\n \n```bash\n# redis\n# redis-cli \n# npm / nodejs\n\n# install dependencies\nnpm install\n```\n## Overview\n\n\u003e * Redis instance has 16 databases, DONT NEED PREFIX IN KEYS\n\n``` bash\nredis-cli -n {database_number}\n```\n\n\u003e* Debugging from cli\n\n```bash\nredis-cli monitor\n``` \n\n\u003e * Main commands: KEYS / DEBUG / SCAN / TYPE / EXPIRATE\n\n## String\n\u003e * Basic data type\n\u003e * Main commands: set / get\n\n```bash\nnode examples/datatypes/string.js\n``` \n\n## List\n\u003e * Arrays of strings\n\u003e * Main commands : lpush / lrange / lpop\n\n```bash\nnode examples/datatypes/list.js\n```\n\n### Set\n\u003e * Unique and unordered collection of strings\n\u003e * Main commands: sadd / smember / srem / sscan\n\n```bash \nnode examples/datatypes/set.js\n```\n\n### Hash\n\u003e * Maps between string fields and string values\n\u003e * Perfect data type to represent objects\n\u003e * Main commands: hset / hmset / hget / hgetall / hscan\n\n```bash \nnode examples/datatypes/hash.js\n```\n\n### Sorted Sets\n\u003e * Similarly to Redis Sets, non repeating collections of Strings.\n\u003e * Every member of a Sorted Set is associated with score\n\u003e * Main commands: zadd / zrangebyscore\n\n```bash \nnode examples/datatypes/sorted-set.js\n```\n\n### Streams\n\u003e * New data type from Redis 5\n\u003e * Goal handle large amount of data (example: chat history, logs, etc)\n\u003e * Main commands: xadd / xread \n\n```bash \nnode examples/datatypes/stream.js\n```\n\n# Transactions\n\n### COMMANDS MULTI, EXEC, DISCARD and WATCH\n\u003e * They allow the execution of a group of commands in a single step\n\u003e * All the commands in a transaction are serialized and executed sequentially.\n\u003e * Atomicity (either all occur or nothing occurs)\n\n```bash \nnode examples/transactions/multi-exec.js\n```\n\n\n\n### LUA SCRIPT\n\n\u003e * You can encapsulate some complex operations in a script and your data layer will perform the atomic\n\n```bash \nnode examples/transactions/rewards.js\nnode examples/transactions/lua-script.js\n```\n\n# Message Queues\n\n* PUBLISH / SUBSCRIBE\n\n![alt text](images/pubsub.png)\n\n\npros\n\u003e * Memory efficiency \n\u003e * Group messagingsS\n\u003e * Examples: notifications, chats, etc.\n\n\ncons\n\u003e * High chance loss message\n\n```bash\nnode pubsub.js\n```\n\n* BRPOPLPUSH / RedisSMQ\n\n\n![alt text](images/rpoplpush.png)\n\n\u003e * Message only will be consumed by one consumer\n\u003e * Less memory efficiency\n\n```bash\nnode examples/queues/create.js\nnode examples/queues/producer.js\nnode examples/queues/consumer.js\n```\n\n# Everyone should read\n\n[https://redis.io/topics/introduction](https://redis.io/topics/introduction)\n\n[https://dzone.com/articles/how-redis-is-used-in-practice](https://dzone.com/articles/how-redis-is-used-in-practice)\n\n[https://www.bogotobogo.com/DevOps/Redis/Redis_vs_Memcached.php](https://www.bogotobogo.com/DevOps/Redis/Redis_vs_Memcached.php)\n\n[https://matt.sh/what-is-redis](https://matt.sh/what-is-redis)\n\n[https://matt.sh/introduction-to-redis-data-types](https://matt.sh/introduction-to-redis-data-types)\n\n[https://www.compose.com/articles/a-quick-guide-to-redis-lua-scripting/](https://www.compose.com/articles/a-quick-guide-to-redis-lua-scripting/)\n\n[https://medium.com/@anvannguyen/redis-message-queue-rpoplpush-vs-pub-sub-e8a19a3c071b](https://medium.com/@anvannguyen/redis-message-queue-rpoplpush-vs-pub-sub-e8a19a3c071b)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjorgemarcial%2Fworkshop-redis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjorgemarcial%2Fworkshop-redis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjorgemarcial%2Fworkshop-redis/lists"}