diff options
author | Adam <Adam@anope.org> | 2013-05-17 23:04:18 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-05-17 23:04:18 -0400 |
commit | 2428264315868f0860f9747c8b005536e5442db6 (patch) | |
tree | 9cd3070f46823ea5f5af32abf84d3c39975e9634 /include/modules/redis.h | |
parent | cc4a14b0badfe3d617ec2dd230d7921f8650a069 (diff) |
Add Redis database support
Diffstat (limited to 'include/modules/redis.h')
-rw-r--r-- | include/modules/redis.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/include/modules/redis.h b/include/modules/redis.h new file mode 100644 index 000000000..4b321a608 --- /dev/null +++ b/include/modules/redis.h @@ -0,0 +1,62 @@ +/* + * + * (C) 2003-2013 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + */ + +namespace Redis +{ + struct Reply + { + enum Type + { + NOT_PARSED, + ERROR, + OK, + INT, + BULK, + MULTI_BULK + } + type; + + Reply() { Clear(); } + void Clear() { type = NOT_PARSED; i = 0; bulk.clear(); multi_bulk_size = 0; multi_bulk.clear(); } + + int64_t i; + Anope::string bulk; + int multi_bulk_size; + std::deque<Reply> multi_bulk; + }; + + class Interface + { + public: + Module *owner; + + Interface(Module *m) : owner(m) { } + + virtual void OnResult(const Reply &r) = 0; + virtual void OnError(const Anope::string &error) { Log(owner) << error; } + }; + + class Provider : public Service + { + public: + Provider(Module *c, const Anope::string &n) : Service(c, "Redis::Provider", n) { } + + virtual void SendCommand(Interface *i, const std::vector<Anope::string> &cmds) = 0; + virtual void SendCommand(Interface *i, const Anope::string &str) = 0; + + virtual bool BlockAndProcess() = 0; + + virtual void Subscribe(Interface *i, const Anope::string &pattern) = 0; + virtual void Unsubscribe(const Anope::string &pattern) = 0; + + virtual void StartTransaction() = 0; + virtual void CommitTransaction() = 0; + }; +} + |