0
votes

I have a Java XPages application with a REST service that functions as an API for rooms & resources database (getting appointments for specific room, creating etc).

The basic workflow is that an HTTP request is being made to a specific REST action, having the room's mail address in the search query. Then in the java code I'm iterating over all documents from the rooms & resources database, until I find a document with the InternetAddress field with the searched mail address.

This isn't as fast as I would like it to be, and there are multiple queries like this being made all the time. I'd like to do some sort of caching in my application, that when one room is found once, it's document UID is being stored in a server-wide cache so next time a request is made for this mail address, I can directly go to the document using getDocumentByUNID(), which I think should be way faster than searching over the entire database.

Is it possible to have such persistent lookup table in Java XPages without having any additional applications, while keeping it as fast as possible? A hash table would be perfect for this.

To clarify: I don't want caching in a single request, because I'm not doing more than one database lookups in a single query, I'd want to keep the caching server-wide, so it would be kept between multiple requests.

1
Sure. What you are looking for is called an application scoped managed bean.Per Henrik Lausten
This is exactly what I needed! I tried it out and it works great. Could you please post an answer so I can accept it?AJ Cole
Excellent! I posted a short answer.Per Henrik Lausten

1 Answers

1
votes

Yes, it is possible to store persistent data. What you are looking for is called an application scoped managed bean.