Skip to content

Conversation

@doomspork
Copy link
Member

No description provided.

@doomspork doomspork force-pushed the feat-redix-lesson branch from a671023 to 8bed803 Compare July 13, 2025 17:59
@doomspork doomspork changed the title feat: New Redix lesson feat: New Redix and Caches lessons, refreshed existing storage lessons. Jul 13, 2025
@doomspork doomspork force-pushed the feat-redix-lesson branch from 8bed803 to 968cee3 Compare July 13, 2025 18:04
@doomspork doomspork force-pushed the feat-redix-lesson branch 2 times, most recently from e7a2e00 to e4ced0f Compare August 4, 2025 17:32
brain-geek
brain-geek previously approved these changes Nov 27, 2025
Copy link
Contributor

@brain-geek brain-geek left a 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.


## Transactions

Transactions provide atomic operations across multiple keys:
Copy link
Contributor

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!?

Copy link
Member Author

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:
Copy link
Contributor

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:
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

Copy link
Member Author

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"])
Copy link
Contributor

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.

Copy link
Member Author

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
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good feedback!


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.
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is schema?

@doomspork
Copy link
Member Author

doomspork commented Nov 28, 2025

@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 🫶

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants