SQL injection is a 25-year-old vulnerability.
It still tops security breach reports every year.
Not because developers don't know about it.
Because string concatenation in queries still feels easier.
"SELECT * FROM users WHERE id = " + userInput
One line. One breach.
Always use parameterized queries.
Never trust user input. Ever.
@code_bytein That's a stupid problem. Do as I do: on every cache request I also do a real database request and compare both! The most recent value wins! Sheesh! Why make it complicated?!?!?
Adding a cache feels like a free win.
It's not.
The moment you cache data, you've created two sources of truth:
The database. And the cache.
They will disagree eventually.
A write happens. The cache doesn't know yet.
A user sees stale data.
This is called cache invalidation.
It's famously one of the hardest problems in computer science.
Caching isn't just "store and serve."
It's "store, serve, and constantly ask: is this still true?"
@javarevisited It's impossible to know if it has anything wrong with it unless I'm also shown the requirements and acceptance criteria. Who am I to say that is not the actual requested behaviour?
Software engineers: Git was named after an insult. 🤔
"Git" is British slang for a stupid, unpleasant person.
In 2005, Linus Torvalds built the first version in days and joked:
"I'm an egotistical bastard. First Linux, now Git."
Twenty years later, the joke stuck.
~95% of developers use it every day.