Commit d824c8de authored by Deepak Prakash Karn's avatar Deepak Prakash Karn
Browse files

Adding new method in cachemdl

Changes related to GetItemsCount Method added in cachemdl
parent 9a33a728
Branches
Tags
1 merge request!91Dpk cache method add
Showing with 33 additions and 0 deletions
......@@ -50,3 +50,8 @@ func (fastCacheHelper *FastCacheHelper) Purge() {
func (fastCacheHelper *FastCacheHelper) Delete(key string) {
fastCacheHelper.FastCache.Delete(key)
}
// GetItemsCount : Number of items in the cache
func (fastCacheHelper *FastCacheHelper) GetItemsCount() int {
return fastCacheHelper.FastCache.ItemCount()
}
......@@ -40,6 +40,8 @@ type clientResponse struct {
QueryState map[string]Statistic `json:"queryState"`
TotalSMS int64 `json:"totalSMS"`
TotalEmail int64 `json:"totalEmail"`
TotalOTP int64 `json:"totalOTP"`
OTPInCache int64 `json:"otpInCache"`
TotalMongoHits int64 `json:"totalMongoHits"`
TotalMySQLHits int64 `json:"totalMySQLHits"`
TotalHits int64 `json:"totalHits"`
......@@ -53,6 +55,8 @@ type clientResponse struct {
type entityHits struct {
TotalSMS int64 `json:"totalSMS"`
TotalEmail int64 `json:"totalEmail"`
TotalOTP int64 `json:"totalOTP"`
OTPInCache int64 `json:"otpInCache"`
Mutex *sync.Mutex
}
......@@ -280,6 +284,26 @@ func EmailHits() {
entityHitsObj.TotalEmail++
}
// OTPHits - update only OTPs hits count for all services -- DPK [12-June-2018]
func OTPHits() {
if !initStatus {
return
}
entityHitsObj.Mutex.Lock()
entityHitsObj.TotalOTP++
entityHitsObj.Mutex.Unlock()
}
// OTPInCache - update only OTPs hits count for all services -- DPK [12-June-2018]
func OTPInCache(count int64) {
if !initStatus {
return
}
entityHitsObj.Mutex.Lock()
entityHitsObj.OTPInCache = count
entityHitsObj.Mutex.Unlock()
}
// SMSHits - update only sms hits count for all services
func SMSHits() {
if !initStatus {
......@@ -329,6 +353,10 @@ func collectStatistics() {
entityHitsObj.Mutex.Lock()
clientResponseData.TotalEmail += entityHitsObj.TotalEmail
entityHitsObj.TotalEmail = 0
clientResponseData.OTPInCache = entityHitsObj.OTPInCache
entityHitsObj.OTPInCache = 0
clientResponseData.TotalOTP += entityHitsObj.TotalOTP
entityHitsObj.TotalOTP = 0
clientResponseData.TotalSMS += entityHitsObj.TotalSMS
entityHitsObj.TotalSMS = 0
entityHitsObj.Mutex.Unlock()
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment