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
- Discussion, Ideas, a TKB, or
- 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?
Inactive User
Page Initialization Script is the best option that enables you to execute business logic using FreeMarker early in a request before any HTML being rendered. Usercache will also work on page init. Might be you are missing something in your code snippet.
Here you can get some more insight view about page init and usercache
https://community.lithium.com/t5/Developer-Knowledge-Base/Cache-the-output-of-a-macro/ta-p/182354