question about cost limit
ljfantin opened this issue · 3 comments
ljfantin commented
I have a question about cost limit in TMMemoryCache.
I set the cost limit, but when I called setObject from TMCache, the cost of object always was zero. Then the memory always was in increasing
Can anyone help me?
TMMemoryCahe Code
- (void)setObject:(id)object forKey:(NSString *)key
{
[self setObject:object forKey:key withCost:0];
}
irace commented
The cost limit is zero by default, and objects have zero cost by default.
Cost limit used used as follows:
- Set a non-zero limit like
memoryCache.costLimit = 100
- Calling
setObject:forKey:withCost:block:
and pass non-zero cost values, e.g.
[memoryCache setObject:foo forKey:@"foo" withCost:25 block:nil];
Once the cost values that you set for each object accumulate to be greater than the limit, the cache will start trimming.
ljfantin commented
But, You are using TMCacheMemory in this case
I want to use TMCache with cost limit.
Is possible ?