using System;
using iiie.CacheControl.Attributes;
using iiie.CacheControl.Business.OutputCache;
using iiie.CacheControl.DBO;
namespace iiie.CacheControl.Business.Attributes
{
///
/// A basic cache control based on time
///
public class TimeCacheControlAttribute : CacheControlAttribute
{
///
/// The number of seconds the cache is valid
///
protected int Seconds { get; set; }
///
/// Contruct a cache control based on time
///
public TimeCacheControlAttribute(int seconds)
{
Seconds = seconds;
}
///
/// Check if data has been cached for less than Senconds seconds
///
/// The cached data
/// True if cache is still valid
protected override bool IsValid(CacheDbo data)
{
return data.Date.AddSeconds(Seconds) >= DateTime.Now;
}
}
}