Race condition

View: New views
1 Messages — Rating Filter:   Alert me  

Race condition

by Erlend Hamnaberg-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a question for you guys.

I am writing a client HTTP cache in scala, and I have race condition issue.

When I'm doing multiple requests after each other, but before the cache has had time to put a response in the cache storage, all the requests go over the wire.

I need a way of throttling the requests, so I can figure out if the first request was cacheable, if not, let all the request through, but if the response was cacheable, the
response should be served from the storage.

The throttle has to be per URI, and only for safe requests (GET, HEAD, TRACE etc).

A solution could be to have an queue of requests which would then be served by the cache after it has figured out if the first request was cacheable.

This repeats when I need to update the response (TTL has run out).


Would it be possible to use Actors for this purpose?

Any pointers?

Thanks

-- Erlend