-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: New Redix and Caches lessons, refreshed existing storage lessons. #3056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
a671023 to
8bed803
Compare
8bed803 to
968cee3
Compare
e7a2e00 to
e4ced0f
Compare
brain-geek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a massive and awesome update.
Added a few notes that might improve readability/consistency.
lessons/en/storage/cachex.md
Outdated
|
|
||
| ## Transactions | ||
|
|
||
| Transactions provide atomic operations across multiple keys: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it different from Cachex.execute!?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I re-wrote this a bit. Let me know if it's clearer.
|
|
||
| ### Read Concurrency | ||
|
|
||
| For tables with many concurrent readers, enable read concurrency: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have both write and read concurrency? It's not obvious if they are mutually exclusive.
|
|
||
| ### Building a Connection Pool | ||
|
|
||
| For high-traffic applications, we might want to use multiple Redis connections. Here's a simple connection pool implementation: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we maybe skip this section? High-traffic applications are definitely out of scope for basic technology lesson.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also thinking of removing the pub/sub section now too. I got carried away and wanted to cover too much to be comprehensive
| # Clean up Redis before each test | ||
| ExUnit.after_suite(fn _results -> | ||
| {:ok, conn} = Redix.start_link(Application.get_env(:my_app, :redis_url)) | ||
| Redix.command!(conn, ["FLUSHDB"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will create weird concurrency test failures if you use it in async: true tests.
Also, ExUnit.after_suite runs it after full suite, not each test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair, let me think about how to capture this best without going to off into the weeds.
| In our `config/test.exs`: | ||
|
|
||
| ```elixir | ||
| config :my_app, :redis_url, "redis://localhost:6379/15" # Use a test database |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the first time we're using redis_url config variable.
Maybe use it in initial supervision tree setup example as well, instead of hardcoding the address?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good feedback!
lessons/en/storage/redix.md
Outdated
|
|
||
| Performance optimization comes through strategic use of pipelining when executing multiple commands, which significantly reduces round-trip time compared to individual command execution. Monitoring this performance through telemetry allows us to track command execution times and overall connection health, helping identify issues before they impact users. | ||
|
|
||
| Data management practices are equally important: use consistent key naming patterns to avoid conflicts and simplify debugging, and always set appropriate TTLs on cached data to prevent memory bloat and ensure data freshness. For operations requiring atomicity across multiple commands, Redis transactions using MULTI/EXEC provide the necessary guarantees to maintain data consistency. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MULTI hasn't been mentioned once in lesson. My guess you're taking about Redix.pipeline! in this case.
| In this case, we are passing in the node associated with our IEx session. | ||
|
|
||
| ## Nodes | ||
| This command creates a new schema on the current node. After running this, you'll notice a new directory in your current working directory named something like `Mnesia.nonode@nohost` - this is where Mnesia stores its data files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is schema?
Co-authored-by: Oleksandr Rozumii <brain-geek@users.noreply.github.com>
e418813 to
a6b9051
Compare
|
@brain-geek thank you, thank you! I've been slowly chipping away at these lessons locally as I get back into the flow of writing lessons and explore some potential changes. Let me work through your feedback and other changes, then I'll tag you for another look 😁 I also screwed up using 1 PR for all the lessons, I wasn't anticipating getting reviews but I love it 🫶 |
No description provided.