UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'HW//2troHCKOodHUBwBUHgNTx2mQa0tV50Z19MAhsbc=' 
WHERE 
  key_id = '507d5f45699df064d2ded6239adf70ea9910f1160560bf9c0972b95dc15f2d36' 
  AND (
    token = 'HW//2troHCKOodHUBwBUHgNTx2mQa0tV50Z19MAhsbc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00027