Question about named query cache management

Hi @KathyApplebaum
In case of a select named query with parameters, I suppose that the cache doesn’t take care of the value of the query parameter ?
Example : named query “select”, param1
if we execute the query with param1 = A and the with param1= B, the named query reset the cached result or keep a cached result for the query with param 1 = A and another cached result for the query with param 2 = B ???

The ‘cache key’ that is used for caching is derived from the resource ID, the arguments, the string body of the query itself, and the database that it executes against.

1 Like

For the arguments, you mean the query parameters, or the query parameters AND the value of these parameters ?

The values of the arguments.

So in your example that query will be cached twice – once for param1 = A and once for param1= B

Thanks for these clarifications, I’ve just seen the doc is quite detailed about named query behaviour…:blush:
In the doc, I suppose that “Once the lifespan expires, the cache is invalidated” means that for the case of a named query cached twice: with param1 = A and param 1 = B, both cached result are invalidated ?

Each result is invalidated separately. They are treated as totally different things.

1 Like