Example #1
0
        private void CreateCache()
        {
            if (_ignite.GetCacheNames().Contains(StreamData.Name))
            {
                return;
            }

            ICache <long, object>?cache;

            if (!string.IsNullOrEmpty(StreamData.IndexType) && StreamData.IndexFields != null &&
                StreamData.IndexFields.Any())
            {
                QueryEntity queryEntity = new QueryEntity
                {
                    KeyType       = typeof(long),
                    ValueTypeName = StreamData.IndexType,
                    Fields        = StreamData.IndexFields
                                    .Select(item => new QueryField {
                        Name = item.Key, FieldTypeName = item.Value
                    }).ToList()
                };

                CacheConfiguration cacheConfiguration = new CacheConfiguration(StreamData.Name, queryEntity);
                cache = _ignite.CreateBinaryCache <long>(cacheConfiguration);
            }
            else
            {
                cache = _ignite.CreateBinaryCache <long>(StreamData.Name);
            }

            // Consider alternative implementation
            if (_ignite.GetAtomicLong($"{StreamData.Name}_Query", 0, true).CompareExchange(1, 0) == 0)
            {
                //Dispose handle?
                cache.QueryContinuous(new ContinuousQuery <long, object>(new EmptyListener())
                {
                    Filter = new RemoteFilter(StreamData.Name)
                });
            }
        }