O
O
obvilion2017-10-25 23:18:25
PHP
obvilion, 2017-10-25 23:18:25

Memcached and getting the number of certain values?

Hello.
There are cells of type key_1 key_2, added by the $cache->set() method, there can be from 100 to 3000 such cells (server memory allows), and so, I need to get the number of such cells.
I tried to do: $cache->get('key_#'), but nothing worked, false was returned via var_dump().

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg, 2017-10-26
@obvilion

Try using the Memcache::getStats attribute curr_items to get the number of items stored.
If you are only interested in elements with keys like 'key_#' then you can try Memcached::getAllKeys to get all keys. And then make a selection of the necessary ones and calculate the total number.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question