Forum Discussion

Inactive User's avatar
Inactive User
7 years ago

usercache: where's the earliest place I can usercache.put? Page Init doesn't seem to work.

I have a test to do on user roles and groups that I'd like to do as early as possible on page load, and keep it in the cache. (i.e., what private groups are they allowed access to). Right now I'm using LiQL like so:

 

SELECT count(*) FROM categories WHERE depth = 2 and parent_category.id = 'private-support'

This results in all the private categories they have access to, usually one. Within those, there are either 

  1. Discussion, Ideas, a TKB, or
  2. Just a Lithium group

Case 1: continue to the Category (i.e., ClientName Private Support)

Case 2: If it's just the group I am redirecting the page to the actual group rather than the parent category containing it, for user simplicity. This is why it's in page init, so the redirect can happen on server side before any HTML is written

 

Since I'm running the query there, I'd like to be able to use usercache.put in the page init to keep that for other components to use rather than repeat the queries, but it doesn't seem to work. Is that by design? A bug? 

 

If it's not permissible in page init, where else can I put that query so that it happens as early as possible?