How to read multiple values from cache at once? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12) +--- Thread: How to read multiple values from cache at once? (/showthread.php?tid=630) |
How to read multiple values from cache at once? - sujit510 - 12-28-2014 Hello everyone, I am using memcached in CI and I have saved user information in cache with keys as user_1, user_2, and so on. While reading them back from cache, I am using iteration as follows - for ($i = 1, $i <= 10; $i++) { $UserData = $this->cache->memcached->get("user_" . $i); //And then process $UserData } But when I checked the performance, I found that it takes time due to reading the cached value in iterations. I want to know if there is any way where I can get all cached values at once by supplying array of keys.. something like following - for ($i = 1, $i <= 10; $i++) { $userIDArray[] = "user_" . $i; } $UserData = $this->cache->memcached->get($userIDArray); Thanks. RE: How to read multiple values from cache at once? - Rumolt - 12-29-2014 No way as I know if you are using memcached. If you are using Redis, you can read multiple values at once. https://github.com/phpredis/phpredis#keys-getkeys |