Seth
Seth

Reputation: 6832

What happens a hapi server method with caching gets called concurrently?

Suppose I have a server method

server.method('foo', foo, { cache: { expiresIn: ###; } });

and suppose the first call to foo takes 15 seconds.

What will hapi do if a second request calls server.methods.foo() a couple seconds after a first request calls it?

Upvotes: 2

Views: 203

Answers (1)

arb
arb

Reputation: 7863

As long as the cache isn't stale, hapi will short-circuit the method and return the cached value. If it's stale, the foo method will run again, rehydrate the cache, and return the result.

Upvotes: 2

Related Questions