Cacheing data in Stateless SessionBean


EJB design: Cacheing data in Stateless SessionBean

  1. Cacheing data in Stateless SessionBean (2 messages)

        We're doing a CPU intensive calculations in the server side which are not specific to a client. Is it possible to cache the calculate data in a stateless SessionBean? The client passes an ID and request for the calculate data for that ID, if there is cached data for the at ID, the stateless SessionBean returns the data to the client if not it performs the calculations, cache the data for and sends the result to the client.

    If it is not possible to store it in a stateless SessionBean then what is the best approach to implement the above problem?

  2. yes, you can cache stuff in a slsb. things will get a little tricky if you start running things in a cluster and need to sync up all the caches. depends on your exact heads. this aside, the simply solution is just to have a static object in the slsb class.

  3. HI,
        If I've a static attribute within my stateless SessionBean (SLSB) then the EJB container would treat it as a stateless their by allowing multiple clients to acess the same SLSB. Right?
    Also, the data for the SLSB cache comes from the EntityBeans. If there is a database change and if I use CMP, then the affected EntityBeans will be recached by the EJB Container. In this case, is there a simple mechanism I can use within the SLSB to reach the data?