예제 #1
0
        public async Task <IBlobCache> Create(HostAddress hostAddress)
        {
            var environment = OperatingSystem.Environment;
            // For GitHub.com, the cache file name should be "api.github.com.cache.db"
            // This is why we use ApiUrl and not CredentialCacheHostKey
            string host          = hostAddress.ApiUri.Host;
            string cacheFileName = host + ".cache.db";

            var userAccountPath = Path.Combine(environment.GetApplicationDataPath(), cacheFileName);

            // CreateDirectory is a noop if the directory already exists.
            OperatingSystem.Directory.CreateDirectory(Path.GetDirectoryName(userAccountPath));

            var cache   = BlobCacheFactory.CreateBlobCache(userAccountPath);
            var version = await cache.GetOrCreateObject <int>(CacheVersionKey, () => 0);

            if (version != CacheVersion)
            {
                await cache.InvalidateAll();

                await cache.InsertObject(CacheVersionKey, CacheVersion);
            }

            return(cache);
        }
예제 #2
0
        public IBlobCache Create(HostAddress hostAddress)
        {
            var environment = OperatingSystem.Environment;
            // For GitHub.com, the cache file name should be "api.github.com.cache.db"
            // This is why we use ApiUrl and not CredentialCacheHostKey
            string host          = hostAddress.ApiUri.Host;
            string cacheFileName = host + ".cache.db";

            var userAccountPath = Path.Combine(environment.GetApplicationDataPath(), cacheFileName);

            // CreateDirectory is a noop if the directory already exists.
            OperatingSystem.Directory.CreateDirectory(Path.GetDirectoryName(userAccountPath));
            return(BlobCacheFactory.CreateBlobCache(userAccountPath));
        }