示例#1
0
 // Thread safe method
 public HttpResponseMessage Get(CachedLuisData data, string utterance)
 {
     lock (data)
     {
         return(data.Get(utterance));
     }
 }
 public CachedLuisRecognizer(
     LuisAdaptiveRecognizer recognizer,
     CachedLuisManager manager)
 {
     _recognizer        = recognizer;
     _cachedLuisManager = manager;
     _cachedLuisData    = _cachedLuisManager.Add(_recognizer);
 }
示例#3
0
        public CachedLuisData Add(LuisAdaptiveRecognizer recognizer)
        {
            var key = ComputeDataKey(recognizer);

            if (_datas.TryGetValue(key, out CachedLuisData data))
            {
                return(data);
            }
            data = new CachedLuisData(recognizer);
            _datas.Add(key, data);
            return(data);
        }
示例#4
0
 // Thread safe method
 public void Set(CachedLuisData data, string utterance, HttpResponseMessage message)
 {
     lock (data)
     {
         var bytes = data.Set(utterance, message);
         if (_options.CachePolicy == CachedLuisOptions.CachePolicyType.FixForEach)
         {
             long target = _options.MaxBytes / _datas.Count;
             while (bytes > target)
             {
                 bytes = data.Remove();
             }
         }
     }
 }