2011-12-02 1 views
2

우리는 Windows Server AppFabric Cache 6.1 x64를 사용합니다. Microsoft.ApplicationServer.Caching.DataCache의 인스턴스가 있고 키/영역으로 객체를 가져 오려고하면 DataCacheException이 발생합니다. 영역 이름에 '!' 또는 '.':AppFabric 캐시의 지역 이름 제한

ErrorCode<ERRCA0018>:SubStatus<ES0001>:The request timed out. 

'-', '_'는 괜찮습니다. 그러나 모든 문자는 항목 키에는 적합하지만 지역 이름에는 적합하지 않습니다. MSDN은 제한 사항에 대해 침묵합니다. 왜? 어떻게 그걸 피합니까?

답변

1

이 하나와 함께 종료 :

static Regex regex = new Regex(@"[^a-zA-Z_\-\d]", RegexOptions.Compiled); 

    /// <summary> 
    /// Fixes invalid characters in region names that cause 
    /// DataCacheException ErrorCode<ERRCA0018>:SubStatus<ES0001>:The request timed out. 
    /// </summary> 
    /// <param name="name">Region name to process.</param> 
    /// <returns>Escaped name where all invalid characters are replaced with their hex code.</returns> 
    protected internal static string Escape(string name) 
    { 
     if (string.IsNullOrEmpty(name)) 
      return name; 

     string result = regex.Replace(name, m => ((int)m.Value.First()).ToString("X")); 
     return result; 
    }