-
Notifications
You must be signed in to change notification settings - Fork 29
/
SYCache.h
73 lines (47 loc) · 1.58 KB
/
SYCache.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// SYCache.h
// SYCache
//
// Created by Sam Soffes on 10/31/11.
// Copyright (c) 2011 Synthetic. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface SYCache : NSObject
@property (nonatomic, copy, readonly) NSString *name;
///-------------------------------
/// @name Getting the Shared Cache
///-------------------------------
+ (SYCache *)sharedCache;
///-------------------
/// @name Initializing
///-------------------
- (id)initWithName:(NSString *)name;
///-----------------------------
/// @name Getting a Cached Value
///-----------------------------
- (id)objectForKey:(NSString *)key;
- (void)objectForKey:(NSString *)key usingBlock:(void (^)(id object))block;
- (BOOL)objectExistsForKey:(NSString *)key;
///----------------------------------------
/// @name Adding and Removing Cached Values
///----------------------------------------
- (void)setObject:(id)object forKey:(NSString *)key;
- (void)removeObjectForKey:(id)key;
- (void)removeAllObjects;
///-------------------------------
/// @name Accessing the Disk Cache
///-------------------------------
/**
Returns the path to the object on disk associated with a given key.
@param key An object identifying the value.
@return Path to object on disk or `nil` if no object exists for the given `key`.
*/
- (NSString *)pathForKey:(NSString *)key;
@end
#if TARGET_OS_IPHONE
@interface SYCache (UIImageAdditions)
- (UIImage *)imageForKey:(NSString *)key;
- (void)imageForKey:(NSString *)key usingBlock:(void (^)(UIImage *image))block;
- (void)setImage:(UIImage *)image forKey:(NSString *)key;
@end
#endif