问题描述:

I'm writing a Zend Framework 2 application on PHP 7 and using APCu (wrapped by the Zend\Cache\Storage\Adapter\Apcu).

Now I have a case, where the cached data needs to be filtered dynamically. E.d.: An autocomplete form input field foo, that should suggest different sets of foo for different values of the field foo or/and another field bar.

The SQL statements behind it look like this:

SELECT name FROM countries WHERE countries.name LIKE %en%

-> should find "Arg[en]tina", "Arm[en]ia", "B[en]in", "Turkm[en]istan" etc.

or

SELECT name FROM countries WHERE countries.continent_id = 2

-> should find "Afghanistan", "Armenia", "Azerbaijan" etc. (2 = Asia)

or

SELECT name FROM countries WHERE countries.continent_id = 2 AND countries.name LIKE %en%

-> should find "Arm[en]ia", "Turkm[en]istan" etc. (2 = Asia)

How to filter the cache?

(Do I need to switch to another ZF cache storage adapter or even to another PHP cache extension? Which ZF cache adapters / PHP extensions support filtering?)

相关阅读:
Top