示例#1
0
        protected void AddToCache(AccountModelBase account, DirectoryModel directory)
        {
            if (directory == null)
            {
                throw new ArgumentNullException(nameof(directory));
            }

            var hash = account.GetHashCode();

            if (!string.IsNullOrEmpty(directory.Path))
            {
                hash += directory.Path.GetHashCode();
            }

            Cache.Set(hash, directory);
        }
示例#2
0
        protected DirectoryModel GetFromCache(AccountModelBase account, DirectoryModel directory)
        {
            var hash = account.GetHashCode();

            if (directory != null)
            {
                hash += directory.GetHashCode();
            }

            if (Cache.TryGetValue(hash, out DirectoryModel dir))
            {
                return(dir);
            }

            return(null);
        }