Cuando se usa Cache.Add, ¿se lanza una excepción si la clave ya existe o falla de forma silenciosa?
He leído en todas partes que el método Agregar falla si ya existe, pero ¿produce una excepción o falla silenciosamente?
Estoy escribiendo una aplicación web multiproceso donde aún no debería existir y causará problemas si sobrescribo el caché, por lo que no puedo usar el método Insertar.
¿Sería esto algo que pudiera hacer?
try
{
HttpContext.Current.Cache.Add("notifications", notifications, null,
System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromHours(8),
System.Web.Caching.CacheItemPriority.High, null);
}
catch
{
//do whatever if notifications already exist
}
Gracias por cualquier respuesta :)