UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'ZXndRXw7kulxwCSWNwInNeweSsBSwQHMrkBXMOE6Jis=' 
WHERE 
  key_id = '4732f303215c31e840db6d108b1666bfccf97218c762bc322776e652a7ef7b86' 
  AND (
    token = 'ZXndRXw7kulxwCSWNwInNeweSsBSwQHMrkBXMOE6Jis=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00070