Remix.run Logo
flaghacker 2 hours ago

What would be the point of embedding Redis into an application? What's the advantage of using Redis over using the builtin (or third party) data structures of the language the application is developed in?

I'm asking as a non-webdev who never quite got what Redis actually does, but would love to learn.

freakynit an hour ago | parent | next [-]

Probably because Redis gives you a very well-defined/understood set of rich data structures with built-in behavior like TTL, atomic operations, eviction, and persistence. These things are otherwise usually scattered across native types, helper classes, or entirely separate libraries.

stingraycharles an hour ago | parent [-]

It doesn’t seem like the right tool for the job, though. Aren’t your own programming language’s constructs much more well-defined / understood ?

freakynit 36 minutes ago | parent | next [-]

Language's own native data-structures are generally much more capable and vast. 99%+ developers use only a very limited set of those capabilities. This approach packages those most used ones into a nice, consistent DSL.

It's similar in effect to what busybox does to shell utilities, though the motives are different.

lpapez 42 minutes ago | parent | prev [-]

I use PHP. None of the language tools or constructs available to me are adequate.

https://blog.codinghorror.com/the-php-singularity/

stingraycharles 34 minutes ago | parent [-]

And you want to embed Redis inside PHP as a solution?? That’s nuts.

sinpif a few seconds ago | parent [-]

Where else could they store their serialized PHP data structures? (just kidding)

razighter777 an hour ago | parent | prev | next [-]

In practice, mostly scaling sessions and ephemeral data (caching) across multiple intances of a microservice on multiple machines. Seperating the kv store and the application allows upgrading each application while retaining availability and avoiding loss of session data.

mystifyingpoi an hour ago | parent | prev | next [-]

For simple cases, it is probably a total overkill to even consider it, but for something heavier, embedding the database gives you a chance to trivially migrate later to a separate database server.

thefreeman an hour ago | parent [-]

Redis is not a database. It’s a key / value store.

rytis an hour ago | parent | next [-]

It kind of is a database:

A key-value database, or key-value store, is a data storage paradigm designed for storing, retrieving, and managing associative arrays, a data structure more commonly known today as a dictionary.

https://en.wikipedia.org/wiki/Key–value_database

theultdev an hour ago | parent | prev [-]

that's still a database.

it's not a relational database.

noodletheworld 22 minutes ago | parent | prev [-]

Why would you embed SQLite?

It’s the same use case with a different api.

A typical (meaningful) example might be communication between threads or actors in a single process, or idempotent tests.

As with SQLite, an external xxx that does this for you is certainly better, etc. but it’s convenient sometimes, to have an application that doesn’t go “now before you run this install Postgres…”.

It’s seldom useful for a web app where you control everything.