guy_fawkes
guy_fawkes

Reputation: 965

Caching MySql Select Query Results for a time limit

I have a table that contains the information about the current location(lat,lng) of user and from my php script i will query the table to find the other users that are surrounding him within some distant(like 50Miles). And each of the=is query may result large data set.

The above query is executed more in my app. But I know that the result contains same data for a user at least for 5 mins.

If i cache the sql query for 5 mins for particular user then i can read from cache instead of querying. After 5 mins i have to query the table as the other users location get updated.

How to solve the above situation ? Any caching techniques for php and mysql ?

Thanks, Seshachalam M

Upvotes: 0

Views: 361

Answers (1)

Nil'z
Nil'z

Reputation: 7475

There is an option for query caching in application/config/database.php, Change the following lines.

$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';

In addition to this you can also see:
1. How to use memcached from codeigniter
2. http://ellislab.com/codeigniter/user-guide/libraries/caching.html

Upvotes: 1

Related Questions