Can you put a write lock on a cache entry?

Is there a way to stop another request thread updating a cache entry whilst you are using it.

Scenario is that we want to limit the number of failed login attempts by an end user and lock the account once the limit has been exceeded. We were planning on storing the failed attempts in the cache but that seems unsafe as a large number of failed requests for a single user in a short period of time could result in read, read, read, write, write, write scenario as opposed to the desired read, write, read, write, read write. That would mean that you could easily exceed the allowed number of requests before locking kicked in.

0 2 198
2 REPLIES 2

you want to limit the failed login attempts -> so I think you could use Quota policy, something like this

<Identifier ref="failed_loginuser"/> 
<Interval>1</Interval>
<TimeUnit>month</TimeUnit>
<Allow countRef="max_login_attempts"/>

A flow can be implemented as

Client Request ---> Check Credentials ---- if invalid creds ---> ApplyQuota --- if Quota exceeded ---> Lock user account

Thanks Mukundha. I didn't realise you could use this for that purpose but I'll look into it now.