RegexBot/Services/EntityCache/EntityCacheService.cs
Noi 1149f2800d Reorganized project
Moved modules into the assembly itself to simplify development of
further features and reduce complexity in building this project.

Additionally, many small adjustments were made, including:
- Add documentation to most public methods that had it missing
- Minor style updates
- Updated readme to reflect near-completion of this rewrite
- Remove any last remaining references to old project name Kerobot
- Update dependencies
2022-07-20 18:55:08 -07:00

30 lines
1 KiB
C#

using RegexBot.Data;
namespace RegexBot.Services.EntityCache;
/// <summary>
/// Provides and maintains a database-backed cache of entities.
/// </summary>
class EntityCacheService : Service {
private readonly UserCachingSubservice _uc;
private readonly MessageCachingSubservice _mc;
internal EntityCacheService(RegexbotClient bot) : base(bot) {
// Currently we only have UserCache. May add Channel and Server caches later.
_uc = new UserCachingSubservice(bot);
_mc = new MessageCachingSubservice(bot, Log);
}
// Hooked
internal CachedUser? QueryUserCache(string search)
=> _uc.DoUserQuery(search);
// Hooked
internal CachedGuildUser? QueryGuildUserCache(ulong guildId, string search)
=> _uc.DoGuildUserQuery(guildId, search);
// Hooked
internal event RegexbotClient.EcMessageUpdateHandler? OnCachePreUpdate {
add { lock (_mc) _mc.OnCachePreUpdate += value; }
remove { lock (_mc) _mc.OnCachePreUpdate -= value; }
}
}