XF 2.1 User Caching type question

SneakyDave

Well-known member
I need the ability to cache a small amount of data used in the forum_list for a period of time. This data isn't in a table, so looking around, it appears that I would use some of the methods in the SessionActivity repository to store this data, per user.

Is that the right place to look?
 
I'm new to this whole thing so I will let someone else step in. But I believe most of the caching is stored in xf_data_registry table and also you could use simpleCache() to cache whatever it is you need. Also SessionActivity repository is a good place to look depending on what you need. I used it for my most ever online add-on for xenforo 2 a while back.

Your looking in the right place. I'll let someone else step in from here just wanted to mention that as @Sim taught me this
 
I just want to save it a few minutes. It's basically a fake online users widget and I just want to cache the usernames for x amount of minutes or so.
 
@Brad Padgett I'll take a look at your most ever online addon, and see how you used SessionActivity. It would probably make sense for me to use that also. Thanks.

Edit: Looks like your addon is using SimpleCache, which is I was originally going to use, but I thought for a widget, it was a little overkill.
 
Last edited:
Back to this topic. I'm trying to use SimpleCache, but I was getting an error which I thought was a template error, but it's actually something worse, lol:
Template Compilation Error
public:forum_list - Entities cannot be serialized or unserialized in /var/www/public/xf2/src/XF/Mvc/Entity/Entity.php:1966

So this is happening because I'm trying to use SimpleCache to save the array of $users that are online. Unfortunately, it looks like I can't do that because SimpleCache won't serialize Entities, which exist in $users.

So I don't think SimpleCache will work in this instance. Will have to try to find something else that'll work. Didn't take this much effort with XF 1.x

Edit: To simply the whole thing, I converted my addon to not use Entities (I just need strings of usernames), so I'm sticking with SimpleCache for now.
 
Last edited:
Back
Top Bottom