UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'iJQelunwRSFVWtZVDHGWsBV0Yhuk4q+2agA2shkScXw=' 
WHERE 
  key_id = '173f09081e516d137ea9625cd7c258f9ae0f803297279a5d523dc40e8df6437d' 
  AND (
    token = 'iJQelunwRSFVWtZVDHGWsBV0Yhuk4q+2agA2shkScXw=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00037