Handling/searching Temporary Data


I’m pulling information from a server and parsing into an array. I’d like to be able to cache and search this information for about 10 minutes, before polling the server again.

After searching the forums and digging through a few Yii books, I’ve got a few (poorly-formed in my mind) ideas as to how to handle this:


[*]use temporary table(s)

  • data connection must be persistent in order not drop the temporary table after the first query.


  • Are there drawbacks to setting the connection as persistent? I was thinking about creating a second persistent db connection to an additional database with only temp tables an using this to be on the safe side. I’d then leave the primary db connection as not persistent, as it’s been performing well as is. Is this overkill, or would it be beneficial?

  • If this is the way to go, then I’d think I can create a normal activeRecord model, and pass the temp table name in dynamically. I’d then benefit from the sorting, searching, and magic of activeRecord. cgridview and clistview filtering and searching would be nice and easy. Any feedback here?


  • Caching: I think I could just set a property on the model that includes a timestamp indicating the last time the server was polled, and trigger a poll only if needed.



[*]use a model based on


  • This seems possible, but I’m not sure it’s the way to go; I think that a custom search function would need to be created to allow for filtering cgridview and clistviews.

  • Caching could be handled by setting session variables and using a timestamp similar to described above.


I’ve seen a few forum posts regarding caching, etc… but I don’t see anything regarding manipulating and searching that cached data. Any advice would be greatly appreciated.

I would store in the database and update it with fresh copy every time I receive new data

If you are familary with the ‘mongodb’, this would be the right db for you.

You don’t have to care about the array structure (indexed or assoziative, nested, …), you directly save the array into the mongodb and query the data with mongodb-criteria, no need to map the array structure into a db-structure.

And the mongodb is very fast…

If you need a dataprovider for gridview, listview this is possible too.

better of using redis/memcahe instead of mongo

It depends on the array datastructure and how complex is the need to search inside the imported information.

quering mongodb - redis