1
- // PINCache is a modified version of TMCache
1
+ // ALPHACache is a modified version of TMCache
2
2
// Modifications by Garrett Moon
3
3
// Copyright (c) 2015 Pinterest. All rights reserved.
4
4
@@ -14,13 +14,13 @@ NS_ASSUME_NONNULL_BEGIN
14
14
A callback block which provides only the cache as an argument
15
15
*/
16
16
17
- typedef void (^PINDiskCacheBlock )(ALPHADiskCache *cache);
17
+ typedef void (^ALPHADiskCacheBlock )(ALPHADiskCache *cache);
18
18
19
19
/* *
20
20
A callback block which provides the cache, key and object as arguments
21
21
*/
22
22
23
- typedef void (^PINDiskCacheObjectBlock )(ALPHADiskCache *cache, NSString *key, id <NSCoding > __nullable object, NSURL *fileURL);
23
+ typedef void (^ALPHADiskCacheObjectBlock )(ALPHADiskCache *cache, NSString *key, id <NSCoding > __nullable object, NSURL *fileURL);
24
24
25
25
/* *
26
26
`ALPHADiskCache` is a thread safe key/value store backed by the file system. It accepts any object conforming
@@ -104,34 +104,34 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
104
104
/* *
105
105
A block to be executed just before an object is added to the cache. The queue waits during execution.
106
106
*/
107
- @property (copy ) PINDiskCacheObjectBlock __nullable willAddObjectBlock;
107
+ @property (copy ) ALPHADiskCacheObjectBlock __nullable willAddObjectBlock;
108
108
109
109
/* *
110
110
A block to be executed just before an object is removed from the cache. The queue waits during execution.
111
111
*/
112
- @property (copy ) PINDiskCacheObjectBlock __nullable willRemoveObjectBlock;
112
+ @property (copy ) ALPHADiskCacheObjectBlock __nullable willRemoveObjectBlock;
113
113
114
114
/* *
115
115
A block to be executed just before all objects are removed from the cache as a result of <removeAllObjects:>.
116
116
The queue waits during execution.
117
117
*/
118
- @property (copy ) PINDiskCacheBlock __nullable willRemoveAllObjectsBlock;
118
+ @property (copy ) ALPHADiskCacheBlock __nullable willRemoveAllObjectsBlock;
119
119
120
120
/* *
121
121
A block to be executed just after an object is added to the cache. The queue waits during execution.
122
122
*/
123
- @property (copy ) PINDiskCacheObjectBlock __nullable didAddObjectBlock;
123
+ @property (copy ) ALPHADiskCacheObjectBlock __nullable didAddObjectBlock;
124
124
125
125
/* *
126
126
A block to be executed just after an object is removed from the cache. The queue waits during execution.
127
127
*/
128
- @property (copy ) PINDiskCacheObjectBlock __nullable didRemoveObjectBlock;
128
+ @property (copy ) ALPHADiskCacheObjectBlock __nullable didRemoveObjectBlock;
129
129
130
130
/* *
131
131
A block to be executed just after all objects are removed from the cache as a result of <removeAllObjects:>.
132
132
The queue waits during execution.
133
133
*/
134
- @property (copy ) PINDiskCacheBlock __nullable didRemoveAllObjectsBlock;
134
+ @property (copy ) ALPHADiskCacheBlock __nullable didRemoveAllObjectsBlock;
135
135
136
136
#pragma mark -
137
137
// / @name Initialization
@@ -179,7 +179,7 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
179
179
180
180
@param block A block to be executed when a lock is available.
181
181
*/
182
- - (void )lockFileAccessWhileExecutingBlock : (nullable PINDiskCacheBlock )block ;
182
+ - (void )lockFileAccessWhileExecutingBlock : (nullable ALPHADiskCacheBlock )block ;
183
183
184
184
/* *
185
185
Retrieves the object for the specified key. This method returns immediately and executes the passed
@@ -190,7 +190,7 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
190
190
@param key The key associated with the requested object.
191
191
@param block A block to be executed serially when the object is available.
192
192
*/
193
- - (void )objectForKey : (NSString *)key block : (nullable PINDiskCacheObjectBlock )block ;
193
+ - (void )objectForKey : (NSString *)key block : (nullable ALPHADiskCacheObjectBlock )block ;
194
194
195
195
/* *
196
196
Retrieves the fileURL for the specified key without actually reading the data from disk. This method
@@ -202,7 +202,7 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
202
202
@param key The key associated with the requested object.
203
203
@param block A block to be executed serially when the file URL is available.
204
204
*/
205
- - (void )fileURLForKey : (nullable NSString *)key block : (nullable PINDiskCacheObjectBlock )block ;
205
+ - (void )fileURLForKey : (nullable NSString *)key block : (nullable ALPHADiskCacheObjectBlock )block ;
206
206
207
207
/* *
208
208
Stores an object in the cache for the specified key. This method returns immediately and executes the
@@ -212,7 +212,7 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
212
212
@param key A key to associate with the object. This string will be copied.
213
213
@param block A block to be executed serially after the object has been stored, or nil.
214
214
*/
215
- - (void )setObject : (id <NSCoding >)object forKey : (NSString *)key block : (nullable PINDiskCacheObjectBlock )block ;
215
+ - (void )setObject : (id <NSCoding >)object forKey : (NSString *)key block : (nullable ALPHADiskCacheObjectBlock )block ;
216
216
217
217
/* *
218
218
Removes the object for the specified key. This method returns immediately and executes the passed block
@@ -221,7 +221,7 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
221
221
@param key The key associated with the object to be removed.
222
222
@param block A block to be executed serially after the object has been removed, or nil.
223
223
*/
224
- - (void )removeObjectForKey : (NSString *)key block : (nullable PINDiskCacheObjectBlock )block ;
224
+ - (void )removeObjectForKey : (NSString *)key block : (nullable ALPHADiskCacheObjectBlock )block ;
225
225
226
226
/* *
227
227
Removes all objects from the cache that have not been used since the specified date.
@@ -230,7 +230,7 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
230
230
@param date Objects that haven't been accessed since this date are removed from the cache.
231
231
@param block A block to be executed serially after the cache has been trimmed, or nil.
232
232
*/
233
- - (void )trimToDate : (NSDate *)date block : (nullable PINDiskCacheBlock )block ;
233
+ - (void )trimToDate : (NSDate *)date block : (nullable ALPHADiskCacheBlock )block ;
234
234
235
235
/* *
236
236
Removes objects from the cache, largest first, until the cache is equal to or smaller than the specified byteCount.
@@ -239,7 +239,7 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
239
239
@param byteCount The cache will be trimmed equal to or smaller than this size.
240
240
@param block A block to be executed serially after the cache has been trimmed, or nil.
241
241
*/
242
- - (void )trimToSize : (NSUInteger )byteCount block : (nullable PINDiskCacheBlock )block ;
242
+ - (void )trimToSize : (NSUInteger )byteCount block : (nullable ALPHADiskCacheBlock )block ;
243
243
244
244
/* *
245
245
Removes objects from the cache, ordered by date (least recently used first), until the cache is equal to or smaller
@@ -249,15 +249,15 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
249
249
@param byteCount The cache will be trimmed equal to or smaller than this size.
250
250
@param block A block to be executed serially after the cache has been trimmed, or nil.
251
251
*/
252
- - (void )trimToSizeByDate : (NSUInteger )byteCount block : (nullable PINDiskCacheBlock )block ;
252
+ - (void )trimToSizeByDate : (NSUInteger )byteCount block : (nullable ALPHADiskCacheBlock )block ;
253
253
254
254
/* *
255
255
Removes all objects from the cache. This method returns immediately and executes the passed block as soon as the
256
256
cache has been cleared.
257
257
258
258
@param block A block to be executed serially after the cache has been cleared, or nil.
259
259
*/
260
- - (void )removeAllObjects : (nullable PINDiskCacheBlock )block ;
260
+ - (void )removeAllObjects : (nullable ALPHADiskCacheBlock )block ;
261
261
262
262
/* *
263
263
Loops through all objects in the cache (reads and writes are suspended during the enumeration). Data is not actually
@@ -267,7 +267,7 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
267
267
@param block A block to be executed for every object in the cache.
268
268
@param completionBlock An optional block to be executed after the enumeration is complete.
269
269
*/
270
- - (void )enumerateObjectsWithBlock : (PINDiskCacheObjectBlock )block completionBlock : (nullable PINDiskCacheBlock )completionBlock ;
270
+ - (void )enumerateObjectsWithBlock : (ALPHADiskCacheObjectBlock )block completionBlock : (nullable ALPHADiskCacheBlock )completionBlock ;
271
271
272
272
#pragma mark -
273
273
// / @name Synchronous Methods
@@ -280,7 +280,7 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
280
280
281
281
@param block A block to be executed when a lock is available.
282
282
*/
283
- - (void )synchronouslyLockFileAccessWhileExecutingBlock : (nullable PINDiskCacheBlock )block ;
283
+ - (void )synchronouslyLockFileAccessWhileExecutingBlock : (nullable ALPHADiskCacheBlock )block ;
284
284
285
285
/* *
286
286
Retrieves the object for the specified key. This method blocks the calling thread until the
@@ -356,7 +356,7 @@ typedef void (^PINDiskCacheObjectBlock)(ALPHADiskCache *cache, NSString *key, id
356
356
@warning Do not call this method within the event blocks (<didRemoveObjectBlock>, etc.)
357
357
Instead use the asynchronous version, <enumerateObjectsWithBlock:completionBlock:>.
358
358
*/
359
- - (void )enumerateObjectsWithBlock : (nullable PINDiskCacheObjectBlock )block ;
359
+ - (void )enumerateObjectsWithBlock : (nullable ALPHADiskCacheObjectBlock )block ;
360
360
361
361
@end
362
362
0 commit comments