I have completed some work which essentially adds a view counter to profile pages. This is all working great. Part of the request is to display the top X most viewed profiles in a sidebar block. Now, I appreciate I could make use of the caching methods in XenPorta or Widget Framework, but I plan to just add the block to the sidebar using a template hook. So my question is this. If I have a query, like the following which generates the information required, what's the best way to cache it? Code: SELECT user.username,user.user_id,user_profile.view_countFROM xf_user_profile AS user_profile INNER JOIN xf_user AS user ON (user.user_id = user_profile.user_id)ORDER BY view_count DESC LIMIT 10 So how do I execute that query into the cache? How do I then retrieve it from the cache? How do I handle the cache expiring and can I adjust the expiry time? How do I only execute the query once the cache has expired? Any advice gratefully receved!