Im using Yii2 Query Cache in my application. initially i have created 2 functions called list() and cache(), im getting records from Database table in list() and getting records from cache in cache(). in my local machine cache() loads values faster than list() as expected but its reversed in my server so im stuck. can any one pl suggest me go ahead.
reason why your cache is slower then your list function is likely because list is held memory and where as your cache is on the disk, disk is much slower than memory as I said above use redis or memcached adapter if you want faster cache instead of file based adapter.
Usually a relational database engine itself has some built-in cache mechanism. So caching the db-query results in a relatively slower cache medium (e.g. file and ordinary db) may decrease the performance despite your intention.
I would use a memory-based cache like memcache or apcu for it.
redis is better option IMO, company I am helping at the moment, I sugggested we switch from memcached to redis now we utilize it for cache as well as other things like we power the activity stream with redis our geospatial data is also in redis.