NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
载入中...
搜索中...
未找到
session_store_redis.hpp
浏览该文件的文档.
1#ifndef NEFORCE_NETWORK_HTTP_SESSION_STORE_REDIS_HPP__
2#define NEFORCE_NETWORK_HTTP_SESSION_STORE_REDIS_HPP__
3
8
10#ifdef NEFORCE_SUPPORT_HIREDIS
12NEFORCE_BEGIN_NAMESPACE__
13NEFORCE_BEGIN_HTTP__
14
19
28class redis_session_store final : public session_store {
29public:
30 explicit redis_session_store(redis_connect& conn) :
31 conn_(&conn) {}
32
33 optional<http_session> load(const string& id) override;
34 void save(const http_session& session) override;
35 void remove(const string& id) override { conn_->del(prefix_ + id); }
36 NEFORCE_NODISCARD bool exists(const string& id) const override { return conn_->exists(prefix_ + id); }
37 void cleanup() override {}
38 NEFORCE_NODISCARD size_t count() const override { return 0; }
39
40private:
41 redis_connect* conn_;
42 string prefix_{"session:"};
43
44 // TODO: Redis Cluster/Sentinel support — handle MOVED/ASK redirection and automatic failover for HA deployments
45 // TODO: Improved serialization — use JSON or MessagePack instead of key=value& pairs to handle special characters
46 // TODO: Session count implementation — use SCAN/KEYS with prefix to return accurate session count
47};
48 // HTTP
50
51NEFORCE_END_HTTP__
52NEFORCE_END_NAMESPACE__
53#endif
54#endif // NEFORCE_NETWORK_HTTP_SESSION_STORE_REDIS_HPP__
Redis数据库连接实现
可插拔会话存储抽象层
Redis数据库连接类