redisspring-data-redisredis-clusterredissonjcache

is there option provided by redis to do partial updates to cache objects


I am storing data in redis using JCA(java caching api) where key is String and value is Object which is JSON string. I have a requirement to perform partial update to cache value instead of retrieving cache value using key and then modify attribute and perform put operation with latest cache value

{
  "attribute1" : "value1",
   "attribute2 " : [
  {
   "attribute3" : "value3"
  }
]
}

Above is sample json format. As explained above is it possible to update value of attribute1 from value1 to value2 without geting cache value using key in redis


Solution

  • You can use a Lua script, so that using the CJSON Lua library you update the item. I have shared a similar example on How to nest a list into a structure in Redis to reduce top level?

    Not familiar with JCA, so not sure if your client would make it simple to send an EVAL command.