public void Intercept(IInvocation invocation) { var prop = ((IProxyTargetAccessor)invocation.Proxy).GetTargetPropertyInfo(); var setKey = new RedisKeyObject(prop, _commonData.Id); //var accessor = (IProxyTargetAccessor)invocation.Proxy; var original = invocation.Arguments[0]; // Removed null check and return... should remove from rediscache var objectKey = new RedisKeyObject(original.GetType(), string.Empty); // 1 Figure out if this is removing a IRedisObject if (original is IRedisObject) { // Look for cascade, if cascade is false don't do anything for redisobject var deleteCascade = prop.GetCustomAttribute<RedisDeleteCascade>(); if (!(deleteCascade != null && !deleteCascade.Cascade)) { _commonData.RedisObjectManager.RedisBackup?.DeleteHash(objectKey); _commonData.RedisDatabase.GenerateId(objectKey, original, _commonData.RedisObjectManager.RedisBackup); _commonData.RedisObjectManager.DeleteObject(original, objectKey.Id, _commonData.RedisDatabase); } } // Delete the keys // TODO work on Table backup for sets //_commonData.RedisObjectManager.RedisBackup?.DeleteSet((string)invocation.Arguments[0], setKey); _commonData.RedisDatabase.SortedSetRemove(setKey.RedisKey, objectKey.RedisKey); invocation.Arguments[0] = original; invocation.Proceed(); }
public void Intercept(IInvocation invocation) { var prop = ((IProxyTargetAccessor)invocation.Proxy).GetTargetPropertyInfo(); var listKey = new RedisKeyObject(prop, _commonData.Id); var original = invocation.Arguments[0]; // 1 Figure out if this is removing a IRedisObject if (original is IRedisObject) { var deleteCascade = prop.GetCustomAttribute<RedisDeleteCascade>(); var objectKey = new RedisKeyObject(original.GetType(), string.Empty); _commonData.RedisDatabase.GenerateId(objectKey, original, _commonData.RedisObjectManager.RedisBackup); if (!(deleteCascade != null && !deleteCascade.Cascade)) { _commonData.RedisObjectManager.DeleteObject(original, objectKey.Id, _commonData.RedisDatabase); } _commonData.RedisObjectManager.RedisBackup?.RemoveListItem(listKey, objectKey.RedisKey); _commonData.RedisDatabase.ListRemove(listKey.RedisKey, objectKey.RedisKey, 1); } else { RedisValue value; if (_commonData.RedisObjectManager.TryConvertToRedisValue(original, out value)) { _commonData.RedisObjectManager.RedisBackup?.RemoveListItem(listKey, value); _commonData.RedisDatabase.ListRemove(listKey.RedisKey, value, 1); } } invocation.Proceed(); }
public override bool Delete(object obj, Type objType, IDatabase redisDatabase, string id, PropertyInfo basePropertyInfo = null) { var setKey = new RedisKeyObject(basePropertyInfo, id); redisDatabase.KeyDelete(setKey.RedisKey); return true; }
public void Intercept(IInvocation invocation) { var prop = ((IProxyTargetAccessor)invocation.Proxy).GetTargetPropertyInfo(); var hashKey = new RedisKeyObject(prop, _commonData.Id); var accessor = (IProxyTargetAccessor)invocation.Proxy; var original = (accessor.DynProxyGetTarget() as IDictionary)?[invocation.Arguments[0]]; // Removed null check and return... should remove from rediscache // 1 Figure out if this is removing a IRedisObject if (original is IRedisObject) { // Look for cascade, if cascade is false don't do anything for redisobject var deleteCascade = prop.GetCustomAttribute<RedisDeleteCascade>(); if (!(deleteCascade != null && !deleteCascade.Cascade)) { var objectKey = new RedisKeyObject(original.GetType(), string.Empty); _commonData.RedisObjectManager.RedisBackup?.DeleteHash(objectKey); _commonData.RedisDatabase.GenerateId(objectKey, original, _commonData.RedisObjectManager.RedisBackup); _commonData.RedisObjectManager.DeleteObject(original, objectKey.Id, _commonData.RedisDatabase); } } RedisValue value; if (!(invocation.Arguments[0] is RedisValue)) { if (!_commonData.RedisObjectManager.TryConvertToRedisValue(invocation.Arguments[0], out value)) { throw new Exception("Cannot convert to RedisValue"); } } else { value = (RedisValue)invocation.Arguments[0]; } // Delete the keys _commonData.RedisObjectManager.RedisBackup?.DeleteHashValue(value, hashKey); _commonData.RedisDatabase.HashDelete(hashKey.RedisKey, value); invocation.Proceed(); }
public void Intercept(IInvocation invocation) { // The property we are attempting to set var prop = ((IProxyTargetAccessor) invocation.Proxy).GetTargetPropertyInfo(); var setKey = new RedisKeyObject(prop, _commonData.Id); // There should only be one argument we need to get the score var redisObject = invocation.Arguments[0] as IRedisObject; if (redisObject == null) { throw new Exception("Object needs to be an IRedisObject"); } var score = redisObject.GetSetScore(); RedisKeyObject key; // We need to process a proxy if (!(invocation.Arguments[0] is IProxyTargetAccessor)) { var proxy = redisObject.CreateProxy(_commonData, out key); invocation.Arguments[0] = proxy; } else { key = new RedisKeyObject(redisObject.GetType(), string.Empty); _commonData.RedisDatabase.GenerateId(key, invocation.Arguments[0], _commonData.RedisObjectManager.RedisBackup); } if (_commonData.Processing) { invocation.Proceed(); return; } // TODO Redis Backup Entries _commonData.RedisObjectManager.RedisBackup?.AddSetItem(setKey, key.RedisKey, score); _commonData.RedisDatabase.SortedSetAdd(setKey.RedisKey, key.RedisKey, score); _commonData.RedisObjectManager.SaveObject(invocation.Arguments[0], key.Id, _commonData.RedisDatabase); invocation.Proceed(); }
public abstract Task<RedisValue> GetStringAsync(RedisKeyObject key, string table = "string", CancellationToken token = default(CancellationToken));
public abstract Task<HashEntry> GetHashEntryAsync(string valueKey, RedisKeyObject hashKey, CancellationToken token = default(CancellationToken));
public abstract Task<HashEntry[]> GetHashAsync(RedisKeyObject hashKey, CancellationToken token = default(CancellationToken));
public void DeleteString(RedisKeyObject key, string table = "string") { Task.Run(async () => await DeleteStringAsync(key, table)).Wait(); }
public void DeleteSet(RedisKeyObject setKey) { Task.Run(async () => await DeleteSetAsync(setKey)).Wait(); }
public abstract Task DeleteHashValueAsync(HashEntry entry, RedisKeyObject hashKey, CancellationToken token = default(CancellationToken));
public void UpdateString(IDatabase redisDatabase, RedisKeyObject key, string table = "string") { Task.Run(async () => await UpdateStringAsync(redisDatabase, key, table)).Wait(); }
public void UpdateSetItem(RedisKeyObject key, RedisValue value, double score, RedisValue oldValue, double oldScore) { Task.Run(async () => await UpdateSetItemAsync(key, new SortedSetEntry(value, score), new SortedSetEntry(oldValue, oldScore))).Wait(); }
public void UpdateSetItem(RedisKeyObject key, SortedSetEntry entry, SortedSetEntry oldEntry) { Task.Run(async () => await UpdateSetItemAsync(key, entry, oldEntry)).Wait(); }
public abstract Task UpdateListItemAsync(RedisKeyObject key, RedisValue oldValue, RedisValue newValue, CancellationToken token = default(CancellationToken));
public void DeleteHashValue(string valueKey, RedisKeyObject hashKey) { Task.Run(async () => await DeleteHashValueAsync(valueKey, hashKey)).Wait(); }
public void DeleteHashValue(HashEntry entry, RedisKeyObject hashKey) { Task.Run(async () => await DeleteHashValueAsync(entry, hashKey)).Wait(); }
public abstract Task UpdateStringAsync(IDatabase redisDatabase, RedisKeyObject key, string table = "string", CancellationToken token = default(CancellationToken));
public void DeleteList(RedisKeyObject key) { Task.Run(async () => await DeleteListAsync(key)).Wait(); }
public abstract Task AddListItemAsync(RedisKeyObject key, RedisValue value, CancellationToken token = default(CancellationToken));
public abstract Task DeleteSetAsync(RedisKeyObject setkey, CancellationToken token = default(CancellationToken));
public void AddSetItem(RedisKeyObject key, SortedSetEntry entry) { Task.Run(async () => await AddSetItemAsync(key, entry)).Wait(); }
public HashEntry[] GetHash(RedisKeyObject hashKey) { return Task.Run(async () => await GetHashAsync(hashKey)).Result; }
public void AddSetItem(RedisKeyObject key, RedisValue value, double score) { Task.Run(async () => await AddSetItemAsync(key, new SortedSetEntry(value, score))).Wait(); }
public HashEntry GetHashEntry(string valueKey, RedisKeyObject hashKey) { return Task.Run(async () => await GetHashEntryAsync(valueKey, hashKey)).Result; }
public abstract Task AddSetItemAsync(RedisKeyObject key, SortedSetEntry entry, CancellationToken token = default(CancellationToken));
public RedisValue GetString(RedisKeyObject key, string table = "string") { return Task.Run(async () => await GetStringAsync(key, table)).Result; }
public void DeleteHash(RedisKeyObject hashKey) { Task.Run(async () => await DeleteHashAsync(hashKey)).Wait(); }
public void RemoveListItem(RedisKeyObject key, RedisValue value) { Task.Run(async () => await RemoveListItemAsync(key, value)).Wait(); }
public abstract Task DeleteHashAsync(RedisKeyObject hashKey, CancellationToken token = default(CancellationToken));