/// <summary> /// Initializes a new instance of the <see cref="SerializerCacheItem{T}"/> class. /// </summary> /// <param name="properties">The actual properties.</param> /// <param name="value">The cache value.</param> public SerializerCacheItem(ICacheItemProperties <TKey> properties, object value) : this() { Guard.NotNull(properties, nameof(properties)); Guard.NotNull(value, nameof(value)); CreatedUtc = properties.CreatedUtc.Ticks; ExpirationMode = properties.ExpirationMode; ExpirationTimeout = properties.ExpirationTimeout.TotalMilliseconds; Key = properties.Key; LastAccessedUtc = properties.LastAccessedUtc.Ticks; UsesExpirationDefaults = properties.UsesExpirationDefaults; Value = (TValue)value; }
/// <summary> /// Initializes a new instance of the <see cref="SerializerCacheItem{T}"/> class. /// </summary> /// <param name="properties">The actual properties.</param> /// <param name="value">The cache value.</param> public SerializerCacheItem(ICacheItemProperties properties, object value) : this() { Guard.NotNull(properties, nameof(properties)); Guard.NotNull(value, nameof(value)); CreatedUtc = properties.CreatedUtc.Ticks; ExpirationMode = properties.ExpirationMode; ExpirationTimeout = properties.ExpirationTimeout.TotalMilliseconds; Key = properties.Key; LastAccessedUtc = properties.LastAccessedUtc.Ticks; Region = properties.Region; UsesExpirationDefaults = properties.UsesExpirationDefaults; ValueType = properties.ValueType.AssemblyQualifiedName; Value = (T)value; }
/// <summary> /// Initializes a new instance of the <see cref="CacheItemPropertiesFactory" /> class. /// </summary> /// <param name="config">The configuration.</param> public CacheItemPropertiesFactory(IConfigurationService config) { string key; if ((key = config.AppSettings[Constants.DefaultSlidingExpiration]) != null) { if (!int.TryParse(key, out this.slidingExpiration)) { this.slidingExpiration = 1; } } if ((key = config.AppSettings[Constants.DefaultAbsoluteExpiration]) != null) { if (!int.TryParse(key, out this.absoluteExpiration)) { this.absoluteExpiration = 10; } } this.defaultItem = this.Build(); }
/// <summary> /// Creates a new instance of the serializer specific cache item. /// Items should implement <see cref="SerializerCacheItem{T}"/> and the implementation should call /// the second constructor taking exactly these two arguments. /// </summary> /// <param name="properties">The item properties to copy from.</param> /// <param name="value">The actual cache item value.</param> /// <returns>The serializer specific cache item instance.</returns> /// <typeparam name="TCacheValue">The cache value type.</typeparam> protected abstract object CreateNewItem <TCacheValue>(ICacheItemProperties properties, object value);
/// <inheritdoc/> protected override object CreateNewItem <TCacheValue>(ICacheItemProperties properties, object value) { return(new MessagePackCacheItem <TCacheValue>(properties, value)); }
public JsonCacheItem(ICacheItemProperties properties, object value) : base(properties, value) { }
public ProtoBufCacheItem(ICacheItemProperties properties, object value) : base(properties, value) { }
/// <inheritdoc /> protected override object CreateNewItem <TCacheValue>( ICacheItemProperties properties, object value) { return((object)new ProtoBufCacheItem <TCacheValue>(properties, value)); }
/// <summary> /// Creates a new instance of the serializer specific cache item. /// Items should implement <see cref="SerializerCacheItem{T}"/> and the implementation should call /// the second constructor taking exactly these two arguments. /// </summary> /// <param name="properties">The item properties to copy from.</param> /// <param name="value">The actual cache item value.</param> /// <returns>The serializer specific cache item instance.</returns> /// <typeparam name="TCacheValue">The cache value type.</typeparam> protected abstract TValue CreateNewItem(ICacheItemProperties <TKey> properties, TValue value);
public DataContractCacheItem(ICacheItemProperties properties, object value) : base(properties, value) { }
/// <inheritdoc/> protected override object CreateNewItem <TCacheValue>(ICacheItemProperties properties, object value) { return(new DataContractCacheItem <TCacheValue>(properties, value)); }
public MessagePackCacheItem(ICacheItemProperties properties, object value) : base(properties, value) { }