//public virtual void DeleteExpiredCacheUpdates(DateTimeOffset expired) //{ // Retry.Do(() => Database.ExecuteSqlRaw("delete from [" + schemaName + "].[CacheUpdates] where [Timestamp] < @expired", new SqlParameter("expired", expired))); //} public virtual CacheUpdateDto[] GetRecentCacheUpdates(DateTimeOffset since) { return(CacheUpdates .AsNoTracking() .OrderBy(update => update.Timestamp) .Where(update => update.Timestamp > since) .ToArray()); }
private void GenerateCacheUpdates(ObjectChanged[] changedEntries) { if (changedEntries.Length == 0) { return; } //TODO: use correct settings var updateVidyanoCache = ApplicationIntentDeterminer.Repository == ApplicationIntent.ReadWrite; var skipUpdateLogging = false; var isSingleInstance = false; if (updateVidyanoCache && !skipUpdateVidyanoCache) { var updateData = Empty <byte> .Array; var updateId = Guid.NewGuid(); CacheUpdateChange?change = null; string? value = null; if (!skipUpdateLogging) { if (changedEntries.Length == 1) { change = changedEntries[0].Change; value = changedEntries[0].Value; } if (changedEntries.Length < 100 && !isSingleInstance) { updateData = CacheSynchronizer.SerializeChangedEntries(changedEntries); } //cacheUpdateStore.Update(changedEntries, updateId, true, change, value); } try { skipUpdateVidyanoCache = true; if (!skipUpdateLogging && !isSingleInstance) { var update = new CacheUpdateDto(); update.Id = updateId; update.Data = updateData; update.Change = change; update.Value = value; if (updateData.Length == 0) { CacheUpdates.RemoveRange(CacheUpdates); } CacheUpdates.Add(update); cacheUpdateStore.AddProcessedCacheUpdate(update.Id); } base.SaveChanges(); } finally { skipUpdateVidyanoCache = false; } } }