UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'w7RjOqjDcJ215GjrF1oU6zd+CHskORyQXV2VK7Yg0g4=' 
WHERE 
  key_id = '504878118a50e776c363412229497c216bb28b052bf72ca4c54e5973d0a81168' 
  AND (
    token = 'w7RjOqjDcJ215GjrF1oU6zd+CHskORyQXV2VK7Yg0g4=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032