aboutsummaryrefslogtreecommitdiff
path: root/lib/cache.ml
diff options
context:
space:
mode:
authorAdelyn Breedlove <[email protected]>2019-02-11 17:23:59 +0000
committerAdelyn Breedlove <[email protected]>2019-02-11 17:23:59 +0000
commit7c9b809078b5cd53e3d54c0004c683da2ec679af (patch)
tree5a1b165b597fc1ad4167115d9a23b12852a4636b /lib/cache.ml
parentMerge branch 'sharder_fixes' into 'master' (diff)
downloaddisml-7c9b809078b5cd53e3d54c0004c683da2ec679af.tar.xz
disml-7c9b809078b5cd53e3d54c0004c683da2ec679af.zip
Add a cache
Diffstat (limited to 'lib/cache.ml')
-rw-r--r--lib/cache.ml38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/cache.ml b/lib/cache.ml
new file mode 100644
index 0000000..50d431c
--- /dev/null
+++ b/lib/cache.ml
@@ -0,0 +1,38 @@
+open Async
+open Core
+
+module ChannelMap = Map.Make(Channel_id_t)
+module GuildMap = Map.Make(Guild_id_t)
+module UserMap = Map.Make(User_id_t)
+
+type t = {
+ text_channels: Channel_t.guild_text ChannelMap.t;
+ voice_channels: Channel_t.guild_voice ChannelMap.t;
+ categories: Channel_t.category ChannelMap.t;
+ groups: Channel_t.group ChannelMap.t;
+ private_channels: Channel_t.dm ChannelMap.t;
+ guilds: Guild_t.t GuildMap.t;
+ presences: Presence.t UserMap.t;
+ (* messages: Channel_id_t.t GuildMap.t; *)
+ unavailable_guilds: Guild_t.unavailable GuildMap.t;
+ user: User_t.t option;
+ users: User_t.t UserMap.t;
+}
+
+let create () = {
+ text_channels = ChannelMap.empty;
+ voice_channels = ChannelMap.empty;
+ categories = ChannelMap.empty;
+ groups = ChannelMap.empty;
+ private_channels = ChannelMap.empty;
+ guilds = GuildMap.empty;
+ presences = UserMap.empty;
+ unavailable_guilds = GuildMap.empty;
+ user = None;
+ users = UserMap.empty;
+ }
+
+let cache =
+ let m = Mvar.create () in
+ Mvar.set m (create ());
+ m \ No newline at end of file