1

I'm working on Spring redis to cache some big data as list object. Is it possible to do CRUD operation in Redis cache? Also does it provide any help on validating the updated data?

sKhan
  • 9,694
  • 16
  • 55
  • 53
ashK
  • 713
  • 2
  • 11
  • 24
  • Redis, of course, has set (as create and update operation) and delete. So, on what you want to apply the crud operation? – Nebras Feb 01 '16 at 11:19
  • I'm using Spring MVC, the flow is UI -> Redis -> DB. So, whenever there is an update, I want to update/insert Redis and then DB. Will it be possible? Will this cause impact in performance? Similarly, when I want to update, I want to do some validation, is it possible? – ashK Feb 01 '16 at 13:55
  • of course, you can update the cache before saving to DB without any performance lack. So you should update the cache whenever you want to read/write to db and before that you can apply your validation. hope this answer your question! – Nebras Feb 01 '16 at 15:10
  • I'm not too sure, I would think it is possible, but the logic would become complicated, when there is an update in UI, we get to know what row is getting updated and hence we can update the DB easily, but if we want to update in redis first, then we should apply some logic because everything is a key and value. I should find the key first then pick the list, make the chnage in the list and then update the key then DB. Won't it look complicated? – ashK Feb 02 '16 at 08:10
  • you mean that you want to update a value in list in redis and you see that it would be cost a lot to find the value in the list? if this is the case you can use Redis hash instead of list, so every value has a key in the hash and can be accessed directly. check this [link](http://instagram-engineering.tumblr.com/post/12202313862/storing-hundreds-of-millions-of-simple-key-value) it may helps you in how to deal with redis has for optimized performance – Nebras Feb 02 '16 at 09:22
  • Is there a way I can get in touch with you? – ashK Feb 02 '16 at 10:00
  • I need to cache minimum of 1000 records per key, I can do the same kind of divide the row number by 1000 and get the key then get the value by the reminder. But I will have to take care of concurrency, performance etc.. and that is what worrying me.. – ashK Feb 02 '16 at 10:38
  • you should don't worry about performance with Redis. And for concurrency access, From Spring Data Redis Doc: **Once configured, the template is thread-safe and can be reused across multiple instances.** – Nebras Feb 02 '16 at 11:03
  • Thanks, will check and vote up – ashK Feb 03 '16 at 07:51
  • I think there is a problem, at least for my approach. For huge data, I store 100 rows in a key as a list. So if there is an update, I can find the key and value but the problem would how can i refresh the rest of the keys. For example, say I got an delete request to delete 100 rows, eventually I can delete the key which holds that 100 rows, but then the keys also has to get refreshed, if akey, bkey and ckey are the keys, if bkey gets deleted, then ckey should become bkey. Also, when I try to fetch 100 records from DB and redis, the speed almost the same only few ms difference. – ashK Feb 08 '16 at 12:41

0 Answers0