skip to Main Content

I’m trying to build a freelance platform with using MongoDB as main database and RedisDB for caching, but really couldn’t figure out which way is the proper way of caching. Basically I’ll store jwt tokens, verification codes and other stuff with expiration date. On the other hand, let’s say I’ll store 5 big collection as Gigs, JobOffers, Reviews, Users, Companies. I also want to use query them.

Example Use Case 1

Getting job offers only categorised as "Web Design"

Example Use Case 2

Getting job offers only posted by Company X

Option 1

for these two queries i can create two hashes

hash1

"job-offers:categoryId", jobOfferId, JobOffer

hash2

"job-offers:companyId", jobOfferId, JobOffer

Option 2

Using RedisJson and RedisSearch for querying and holding everything in JSON format

Option 3

Using redisSearch with creating multiple hashes

I couldn’t figure out which approach will be best, or is there any other approach which is better than both of them.

2

Answers


    1. good question
    2. as far as I can see, data of redis/part of mongo is stored on RAM, and RAM is more expensive than hard disk, if you don`t care about the price, and you can handle the situations by redis/mongo, and the data can be recovered from AOF/RDB files(or things like that), you can use whichever you want
    3. If you do care about the price of RAM, probably just use a mysql and use
      engine of InnoDB cuz it is cheap and on disk and it can recover and you know a lot of people use them(mysqls,postgres)
    4. If I were you, I probably would choose mysql InnDB, and make the right index, it is fast enough for tables that hold millions of rows.(will get not so good if there are hundreds million rows)
    Login or Signup to reply.
  1. Option 1 seems like suitable for your scenario. Binding job offers with category or company ids is the smartest solution.

    You can use HGETALL to get all fields data from your hashset.

    When using redis as a request caching mechanism, please remember that you have to keep redis cache updated consistently if it is generated from sql or no-sql db.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search