mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-11-01 11:17:51 +00:00
Adding DB Cache
This commit is contained in:
@@ -16,10 +16,10 @@ namespace OpenWifi {
|
||||
|
||||
StorageClass::Start();
|
||||
|
||||
UserCache_ = std::make_unique<OpenWifi::UserCache>(64,900000,true);
|
||||
SubCache_ = std::make_unique<OpenWifi::UserCache>(2048,900000,false);
|
||||
UserTokenCache_ = std::make_unique<OpenWifi::TokenCache>(64,900000, true);
|
||||
SubTokenCache_ = std::make_unique<OpenWifi::TokenCache>(2048,900000,false);
|
||||
UserCache_ = std::make_unique<OpenWifi::UserCache>(64,1200000,true);
|
||||
SubCache_ = std::make_unique<OpenWifi::UserCache>(2048,1200000,false);
|
||||
UserTokenCache_ = std::make_unique<OpenWifi::TokenCache>(64,1200000, true);
|
||||
SubTokenCache_ = std::make_unique<OpenWifi::TokenCache>(2048,1200000,false);
|
||||
|
||||
UserDB_ = std::make_unique<OpenWifi::BaseUserDB>("Users", "usr", dbType_,*Pool_, Logger(), UserCache_.get(), true);
|
||||
SubDB_ = std::make_unique<OpenWifi::BaseUserDB>("Subscribers", "sub", dbType_,*Pool_, Logger(), SubCache_.get(), false);
|
||||
|
||||
@@ -2358,6 +2358,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
inline void Stop() override {
|
||||
std::lock_guard G(Mutex_);
|
||||
Cache_.clear();
|
||||
}
|
||||
|
||||
@@ -2387,6 +2388,7 @@ namespace OpenWifi {
|
||||
return false;
|
||||
}
|
||||
Expired = false;
|
||||
std::lock_guard G(Mutex_);
|
||||
Cache_.update(SessionToken, UInfo);
|
||||
return true;
|
||||
}
|
||||
@@ -2399,6 +2401,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
inline bool IsAuthorized(const std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo, bool & Expired, bool Sub = false) {
|
||||
std::lock_guard G(Mutex_);
|
||||
auto User = Cache_.get(SessionToken);
|
||||
if(!User.isNull()) {
|
||||
if(IsTokenExpired(User->webtoken)) {
|
||||
@@ -2413,7 +2416,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
private:
|
||||
Poco::ExpireLRUCache<std::string,OpenWifi::SecurityObjects::UserInfoAndPolicy> Cache_{1024,1200000 };
|
||||
Poco::ExpireLRUCache<std::string,OpenWifi::SecurityObjects::UserInfoAndPolicy> Cache_{512,1200000 };
|
||||
};
|
||||
|
||||
inline auto AuthClient() { return AuthClient::instance(); }
|
||||
@@ -2427,7 +2430,7 @@ namespace OpenWifi {
|
||||
{
|
||||
}
|
||||
|
||||
void handleRequest(Poco::Net::HTTPServerRequest& Request, Poco::Net::HTTPServerResponse& Response)
|
||||
void handleRequest(Poco::Net::HTTPServerRequest& Request, Poco::Net::HTTPServerResponse& Response) override
|
||||
{
|
||||
Logger_.information(Poco::format("ALB-REQUEST(%s): New ALB request.",Request.clientAddress().toString()));
|
||||
Response.setChunkedTransferEncoding(true);
|
||||
@@ -2669,8 +2672,6 @@ namespace OpenWifi {
|
||||
uint64_t LastUpdate=0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class SubSystemServer;
|
||||
typedef std::map<uint64_t, MicroServiceMeta> MicroServiceMetaMap;
|
||||
typedef std::vector<MicroServiceMeta> MicroServiceMetaVec;
|
||||
@@ -2728,7 +2729,7 @@ namespace OpenWifi {
|
||||
return Poco::Logger::get(Name);
|
||||
}
|
||||
|
||||
inline void Exit(int Reason);
|
||||
static inline void Exit(int Reason);
|
||||
inline void BusMessageReceived(const std::string &Key, const std::string & Message);
|
||||
inline MicroServiceMetaVec GetServices(const std::string & Type);
|
||||
inline MicroServiceMetaVec GetServices();
|
||||
|
||||
Reference in New Issue
Block a user