How to read multiple values from cache at once? |
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.
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 |
Welcome Guest, Not a member yet? Register Sign In |