Files
peko-ios/YuMi/Modules/YMMessage/View/Session/SessionRiskCache.m

51 lines
839 B
Mathematica
Raw Normal View History

2023-07-06 16:54:13 +08:00
//
2023-07-14 18:50:55 +08:00
// SessionRiskCache.m
2023-07-06 16:54:13 +08:00
// YUMI
//
// Created by YUMI on 2022/8/11.
//
2023-07-14 18:50:55 +08:00
#import "SessionRiskCache.h"
#import "AccountInfoStorage.h"
static SessionRiskCache * cache = nil;
2023-07-06 16:54:13 +08:00
2023-07-14 18:50:55 +08:00
@interface SessionRiskCache ()
///
2023-07-06 16:54:13 +08:00
@property (nonatomic,strong) NSCache *cache;
@end
2023-07-14 18:50:55 +08:00
@implementation SessionRiskCache
2023-07-06 16:54:13 +08:00
2023-07-14 18:50:55 +08:00
+ (instancetype)shareCache {
2023-07-06 16:54:13 +08:00
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
2023-07-14 18:50:55 +08:00
cache = [[SessionRiskCache alloc] init];
2023-07-06 16:54:13 +08:00
});
return cache;
}
2023-07-14 18:50:55 +08:00
- (void)saveCloseRisk:(NSString *)userId {
2023-07-06 16:54:13 +08:00
if (userId.length > 0) {
[self.cache setObject:userId forKey:userId];
}
}
2023-07-14 18:50:55 +08:00
- (NSString *)getCloseChatRiskAlert:(NSString *)userid {
2023-07-06 16:54:13 +08:00
if (userid) {
return [self.cache objectForKey:userid];
}
return nil;
}
- (NSCache *)cache {
if (!_cache) {
_cache = [[NSCache alloc]init];
_cache.countLimit = 500;
}
return _cache;
}
@end