UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'NQEg6FSA6j4v72SamYx5cnze/IhoEj4mWGYZdHysV+w=' 
WHERE 
  key_id = 'bc3710ed693d7b5bd82e21d32b4c726459f7c783873b56294480739bebf068e9' 
  AND (
    token = 'NQEg6FSA6j4v72SamYx5cnze/IhoEj4mWGYZdHysV+w=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00041