-
Notifications
You must be signed in to change notification settings - Fork 1
/
EBTwoLevelCache.h
27 lines (20 loc) · 1.09 KB
/
EBTwoLevelCache.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#import <Foundation/Foundation.h>
@class EBDiskCache;
@interface EBTwoLevelCache : NSObject
/* ## Creation */
/* Designated initializer */
/* If `transformer` is nil, the resulting object stores and retrieves NSData objects. */
- (instancetype)initWithMemoryCache: (NSCache *)memoryCache diskCache: (EBDiskCache *)diskCache transformer: (NSValueTransformer *)transformer;
/* ## Properties */
@property(nonatomic, readonly) NSCache *memoryCache;
@property(nonatomic, readonly) EBDiskCache *diskCache;
@property(nonatomic, readonly) NSValueTransformer *transformer;
/* ## Methods */
/* Returns the object from the memory cache if it exists, otherwise goes down to the disk cache and transforms
the data into an object using `transformer`, and then places the object in the memory cache. If no data
exists, returns nil. */
- (id <NSObject>)objectForKey: (NSString *)key;
/* Puts the object in the memory cache, and if `transformer` supports reverse transformation, the object will
be converted to data and stored in the disk cache. */
- (void)setObject: (id <NSObject>)object forKey: (NSString *)key;
@end