8
Wombat
6y

I've implemented an in memory caching system for database queries with Redis in one of the blogs I manage.

Will it work well? Or do you think it will produce issues? I have no experience with Redis yet.

Comments
  • 3
    @linuxxx has experience with it
  • 4
    Define database queries with redis? Redis is an in-memory key-value database so you can't run SQL queries.

    Let me know!
  • 2
    @linuxxx I mean like caching the results. I use a MySQL database.

    I query the database if there is no data in Redis. Then I store the data in redis for 24h. If there is I just render with the data from Redis.
  • 3
    @Wombat Put data in redis where the key is something identifiable (with a prefix maybe?) and put the content as value. You can also set a TTL for redis records.

    This is the exact way of how I handle much-security.nl :) (working on a new article as we speak by the way ;)
  • 2
    @linuxxx that is exactly what I do. I was wondering about problems I will face with this setup. I dunno...

    Mind sharing, when you finish?
  • 2
    @Wombat This sounds good and I'd do it like this as well.

    I'll share when I publish it!
  • 2
    @PonySlaystation interested as well? ;P
  • 2
    @linuxxx Yeah, count me in!
    I've not yet used it yet.
  • 2
    @Wombat how are u dealing with cache updates when those queries become out of date?
  • 1
    @linuxxx does it really make sense to use a redis cache for much-security.nl? I mean, how much traffic do you get and at what point do you decide that caching is needed?

    Also there's a random "string () """ text on the top of the much-security website and the FB post is rendered twice
  • 1
    @DanTzuBoi you can set expiration on keys in Redis. I also set a flag on the posts table, when it's set posts get cached for 24h.
  • 1
    @linuxxx just curioys. I think I already know the answer, but...
    Would reddis happen to have a dependency tree evict mechanism? Like defining which keys key A depends on? So that chanding any of dependencies A would be ruled invalid?

    Now I'm doing all the deps mgmt in-app. Doesn't seem to be very efficient :)
  • 3
    @RememberMe I know about the string and the fb post and nope, caching isn't needed but I just like the site to be very fast :)
  • 3
    @netikras Not entirely sure but not that I know of...
Add Comment