public void Register(Connection connection)
        {
            ConnectionDto connectionDto = new ConnectionDto(
                connection.Name,
                connection.HostName,
                connection.Port);

            this.cacheRegistrationService.Register(connectionDto);
        }
        public void Initialize()
        {
            ConnectionDto connectionDto = new ConnectionDto(
                this.Session.Connection.Name,
                this.Session.Connection.HostName,
                this.Session.Connection.Port);

            SlabsDto slabContainer = this.cacheService.GetSlabs(connectionDto);
        }
        public SlabsDto GetSlabs(ConnectionDto connection)
        {
            SlabsDto slabs = null;

            Cache cache = new Cache(connection);

            cache.Connect();
            slabs = cache.GetSlabs();
            cache.Disconnect();

            return slabs;
        }
        public Collection<ItemDto> GetItems(ConnectionDto connection, SlabDto slab, bool mustRetrieveValues)
        {
            Collection<ItemDto> items = null;

            Cache cache = new Cache(connection);

            cache.Connect();
            items = cache.GetItems(slab);
            cache.Disconnect();

            return items;
        }
        public void TestStoreRetrieve()
        {
            ICacheService service = this.GetService();
            ConnectionDto connection = new ConnectionDto(".", "localhost", 11211);

            const string Key = "test";
            const string Value = "data";

            service.Set(connection, Key, Value);
            string resultValue = service.Get(connection, Key) as string;

            Assert.AreEqual(Value, resultValue);
        }
        public void Register(ConnectionDto connection)
        {
            Cache cache = new Cache(connection);

            try
            {
                cache.Connect();
                cache.Disconnect();

                CacheRegistrationService.Connections.Add(connection);
            }
            catch (Exception ex)
            {
                throw new CacheConnectionException(ex.Message, ex);
            }
        }
        public void LoadConnections()
        {
            string filePath = this.GetFilePath();

            CacheRegistrationService.Connections.Clear();

            if (File.Exists(filePath))
            {
                JsonSerializer serializer = new JsonSerializer();

                serializer.NullValueHandling = NullValueHandling.Ignore;

                using (StreamReader streamReader = new StreamReader(filePath))
                {
                    using (JsonReader jsonReader = new JsonTextReader(streamReader))
                    {
                        ConnectionsDto connectionContainer = serializer.Deserialize<ConnectionsDto>(jsonReader);

                        foreach (ConnectionDto connection in connectionContainer.Connections)
                        {
                            CacheRegistrationService.Connections.Add(connection);
                        }
                    }
                }
            }
            else
            {
                // TODO: remove for prod
                ConnectionDto connection = new ConnectionDto(
                    ConnectionSettings.DefaultConnectionName,
                    ConnectionSettings.DefaultHostName,
                    ConnectionSettings.DefaultPort);

                    CacheRegistrationService.Connections.Add(connection);
            }
        }
        public void FlushAll(ConnectionDto connection)
        {
            Cache cache = new Cache(connection);

            cache.FlushAll();
        }
 internal Connection(ConnectionDto connection)
     : this(connection.Name, connection.HostName, connection.Port)
 {
 }
        public void Set(ConnectionDto connection, string key, object value)
        {
            Cache cache = new Cache(connection);

            cache.Set(key, value);
        }
        public void Replace(ConnectionDto connection, string key, object value)
        {
            Cache cache = new Cache(connection);

            cache.Replace(key, value);
        }
 public void Unregister(ConnectionDto connection)
 {
     CacheRegistrationService.Connections.Remove(connection);
 }
 public Collection<ItemDto> GetItems(ConnectionDto connection, SlabDto slab)
 {
     return this.GetItems(connection, slab, CacheService.MustRetrieveValuesByDefault);
 }
        public object Get(ConnectionDto connection, string key)
        {
            Cache cache = new Cache(connection);

            return cache.Get(key);
        }
Example #15
0
 public Cache(ConnectionDto connection)
     : this(connection.HostName, connection.Port)
 {
 }
        public SlabStatisticsDto GetMetadata(ConnectionDto connection)
        {
            Cache cache = new Cache(connection);

            return cache.GetMetadata();
        }
        public StatisticsDto GetStatistics(ConnectionDto connection)
        {
            Cache cache = new Cache(connection);

            return cache.GetStatistics();
        }
        public void Remove(ConnectionDto connection, string key)
        {
            Cache cache = new Cache(connection);

            cache.Remove(key);
        }