Пример #1
0
        Execute <TEntity>(ICloudTableQuery <TEntity> query)
            where TEntity : ITableEntity, new()
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }

            return(await Task.Run(() =>
            {
                if (cachePolicy == null)
                {
                    return query.Execute(tableReference);
                }

                var cached = new CloudTableQueryCache <TEntity>(query,
                                                                cachePolicy,
                                                                cacheHint);
                return cached.Execute(tableReference);
            }));
        }
Пример #2
0
        public CloudTableQueryCache(ICloudTableQuery <TEntity> query,
                                    CacheItemPolicy policy,
                                    string cacheHint)
        {
            this.query     = query;
            this.cacheHint = cacheHint;

            if (policy == null)
            {
                cacheItemPolicy = new CacheItemPolicy
                {
                    AbsoluteExpiration = DateTime
                                         .UtcNow
                                         .Add(TimeSpan.FromMinutes(1))
                }
            }
            ;
            else
            {
                cacheItemPolicy = policy;
            }
        }
Пример #3
0
 public CloudTableQueryCache(ICloudTableQuery <TEntity> query,
                             CacheItemPolicy policy)
     : this(query, policy, string.Empty)
 {
 }
Пример #4
0
 /// <summary>
 /// Applies a 1 minute cache
 /// </summary>
 public CloudTableQueryCache(ICloudTableQuery <TEntity> query)
     : this(query, null)
 {
 }