i using the following code redis lock , release
var key = "test-x"; redisvalue token = (redisvalue) guid.newguid().tostring(); if(db.locktake(key, token, duration)) { try { // have lock work } { db.lockrelease(key, token); } } my problem:
in unit test calling method 2 times. first time work, second time want obtain lock on specific key, not work. understanding db.lockrelease should release lock, making available second request. i did notice db.lockrelease returns false.
any idea might happening?
the lock key needs unique. using same lock key cache key in code. https://stackoverflow.com/a/25138164:
the key (the unique name of lock in database)
Comments
Post a Comment