Exemplo n.º 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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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();
             }
         }
     }
 }