Ejemplo n.º 1
0
        private static void SimpleValidation()
        {
            // Create cache
            GenericCache <long, string> toStringCache = new GenericCache <long, string>(
                CacheFactory.Build <string>(
                    settings => settings
                    .WithProtoBufSerializer()
                    .WithSQLiteCacheHandle(new SQLiteCacheHandleAdditionalConfiguration {
                DatabaseFilePath = "MyDatabase.sqlite"
            })
                    .Build()));

            // Initial state
            toStringCache.Exists(1).Should().BeFalse();

            // Add
            toStringCache.Add(1, "1").Should().BeTrue();
            toStringCache.Exists(1).Should().BeTrue();

            // Get
            toStringCache.Get(1).Should().Be("1");
        }