Welcome Guest, Not a member yet? Register   Sign In
Logical help for storing data in cache or no
#1

[eluser]veledrom[/eluser]
Hi,

This is pagination purposes.

I have a table with 2.000.000+/- records in database. My query returns average 20.000 records. I store it in cache philsturgeon for 5 minutes so every page request done in 5 minutes reads records from cache, no query sent to database.

I know that we normally send queries to database with LIMIT and OFFSET parts (takes about 2 minutes) but in this case same logic is applied against cache with array_slice(array, OFFSET, LENGTH) function (takes less than half a second).

Do you think sending queries to database is better than using cache in this case, or I'm on right track?


Code:
$cache_name = $this->cache_name_initials . '-' . $postcode . '-' . $within;
  
if (! $this->cache->get($cache_name))
{
$query_result = $this->geomaps_model->get_near_places($postcode, $within);
$cache_content['Created'] = date('H:i:s');
$cache_content['Content'] = $query_result->result();
$this->cache->write($cache_content, $cache_name, $this->cache_timeout);
}

$search_result = $this->cache->get($cache_name);

Thanks


Messages In This Thread
Logical help for storing data in cache or no - by El Forum - 06-11-2012, 02:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB