public static void ToLock(this ILockManager lockManger, string key, string lockValue, Action action) { if (!lockManger.LockKey(key, lockValue)) { throw new MikeException("锁超时"); } try { action(); } catch (Exception ex) { throw new MikeException(ex.Message); } finally { lockManger.UnlockKey(key, lockValue); } }
public IHttpActionResult Lock(LockModel model) { return(Ok(_lock.LockKey(model.LockKey, model.LockValue))); }