Oolite 1.91.0.7645-241119-222d325
Loading...
Searching...
No Matches
OOCache.h
Go to the documentation of this file.
1/*
2
3OOCache.h
4By Jens Ayton
5
6An OOCache handles storage of a limited number of elements for quick reuse. It
7may be used directly for in-memory cache, or indirectly through OOCacheManager
8for on-disk cache.
9
10Every OOCache has a 'prune threshold', which controls how many elements it
11contains, and an 'auto-prune' flag, which determines how pruning is managed.
12
13If auto-pruning is on, the cache will pruned to 80% of the prune threshold
14whenever the prune threshold is exceeded. If auto-pruning is off, the cache
15can be pruned to the prune threshold by explicitly calling -prune.
16
17While OOCacheManager-managed caches must have string keys and property list
18values, OOCaches used directly may have any keys allowable for a mutable
19dictionary (that is, keys should conform to <NSCopying> and values may be
20arbitrary objects) -- an 'unmanaged' cache is essentially a mutable dictionary
21with a prune limit. (Project: with the addition of a -keyEnumerator method and
22sutiable NSEnumerator subclass, and a -count method, it could be turned into a
23subclass of NSMutableDictionary.)
24
25
26Oolite
27Copyright (C) 2004-2013 Giles C Williams and contributors
28
29This program is free software; you can redistribute it and/or
30modify it under the terms of the GNU General Public License
31as published by the Free Software Foundation; either version 2
32of the License, or (at your option) any later version.
33
34This program is distributed in the hope that it will be useful,
35but WITHOUT ANY WARRANTY; without even the implied warranty of
36MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37GNU General Public License for more details.
38
39You should have received a copy of the GNU General Public License
40along with this program; if not, write to the Free Software
41Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
42MA 02110-1301, USA.
43
44*/
45
46#import <Foundation/Foundation.h>
47
48
49enum
50{
53 kOOCacheNoPrune = 0xFFFFFFFFU
54};
55
56
57@interface OOCache: NSObject
58{
59@private
63 BOOL dirty;
64}
65
66- (id)init;
67- (id)initWithPList:(id)pList;
68- (id)pListRepresentation;
69
70- (id)objectForKey:(id)key;
71- (void)setObject:(id)value forKey:(id)key;
72- (void)removeObjectForKey:(id)key;
73
74- (void)setPruneThreshold:(unsigned)threshold;
75- (unsigned)pruneThreshold;
76
77- (void)setAutoPrune:(BOOL)flag;
78- (BOOL)autoPrune;
79
80- (void)prune;
81
82- (BOOL)dirty;
83- (void)markClean;
84
85- (NSString *)name;
86- (void)setName:(NSString *)name;
87
88- (NSArray *) objectsByAge;
89
90@end
@ kOOCacheDefaultPruneThreshold
Definition OOCache.h:52
@ kOOCacheNoPrune
Definition OOCache.h:53
@ kOOCacheMinimumPruneThreshold
Definition OOCache.h:51
BOOL dirty
Definition OOCache.h:63
struct OOCacheImpl * cache
Definition OOCache.h:60
BOOL autoPrune
Definition OOCache.h:62
unsigned pruneThreshold
Definition OOCache.h:61
NSString * name
Definition OOCache.m:401