enormego/EGOCache

Handle cache in diskOperation

huntrax11 opened this issue · 0 comments

would you like to handle cache in disk operation?
You know some code like above-

  • (NSData_)dataForKey:(NSString_)key {
    if([self hasCacheForKey:key]) {
    return [NSData dataWithContentsOfFile:cachePathForKey(key) options:0 error:NULL];
    } else {
    for(NSInvocationOperation* operation in [diskOperationQueue operations]){
    NSInvocation *invocation=[operation invocation];
    NSString *path=nil;
    NSData *data=nil;
    [invocation getArgument:&path atIndex:3];
    if([path hasSuffix:key]){
    [invocation getArgument:&data atIndex:2];
    return data;
    }
    }
    return nil;
    }
    }