Search code examples
redislaravel-5.3predis

Laravel Predis update/delete 1 key in array


For example i have an array/json with 100000 entries cached with Redis / Predis. Is it posible to update or delete 1 or more entries or do i have to generate the whole array/json of 100000 entries? And how can I achieve that?


Solution

  • It is about how you store them if you are storing it as a string then no,

    set key value
    get key -> will return you value
    

    Here value is your json/array with 10000 entries.

    Instead if you are storing it in a hash . http://redis.io/commands#hash

    hmset key member1 value1 member2 value2 ...
    

    then you can update/delete member1 separately.

    If you are using sets/lists you can achieve it with similar commands like lpush/lpop, srem etc.

    Do read the commands section to know more about redis data structures which will give you more flexibility in selecting your structure.

    Hope this helps