UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'p1weVBSBkcuCqCEWl1SBOZbalGJVzW1J47iiejh5z84=' 
WHERE 
  key_id = 'bfaf9ec0e63d6e64574995471379c20ee7039ccb66229f2ac38a82a747a3bf3f' 
  AND (
    token = 'p1weVBSBkcuCqCEWl1SBOZbalGJVzW1J47iiejh5z84=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00023