Monotone-Parent: defafb3d42bb34384a710aa31d323d75bb693172

Monotone-Revision: 9cbd91b1acc90a99245d977eebc9cfaa5013f540

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2009-11-16T15:02:14
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2009-11-16 15:02:14 +00:00
parent e420fd76e9
commit 95c6872a41
4 changed files with 24 additions and 20 deletions
+11 -15
View File
@@ -54,32 +54,20 @@
// high to avoid useless database calls.
static NSTimeInterval cleanupInterval = 300;
static NSMutableDictionary *cache = nil;
static NSMutableDictionary *users = nil;
// localCache is used to avoid going all the time to the memcached server during
// each request. We'll cache the value we got from memcached for the duration
// of the current request - which is good enough for pretty much all caces. We
// surely don't want to get new defaults/settings during the _same_ requests, it
// could produce relatively strange behaviors
static NSMutableDictionary *localCache = nil;
static NSString *memcachedServerName = @"localhost";
static SOGoCache *sharedCache = nil;
#if defined(THREADSAFE)
static NSLock *lock;
#endif
@implementation SOGoCache
#if defined(THREADSAFE)
+ (void) initialize
{
#if defined(THREADSAFE)
lock = [NSLock new];
#endif
}
#endif
+ (NSTimeInterval) cleanupInterval
{
@@ -88,6 +76,8 @@ static NSLock *lock;
+ (SOGoCache *) sharedCache
{
static SOGoCache *sharedCache = nil;
#if defined(THREADSAFE)
[lock lock];
#endif
@@ -100,7 +90,7 @@ static NSLock *lock;
return sharedCache;
}
+ (void) killCache
- (void) killCache
{
#if defined(THREADSAFE)
[lock lock];
@@ -125,6 +115,12 @@ static NSLock *lock;
cache = [[NSMutableDictionary alloc] init];
users = [[NSMutableDictionary alloc] init];
// localCache is used to avoid going all the time to the memcached server during
// each request. We'll cache the value we got from memcached for the duration
// of the current request - which is good enough for pretty much all caces. We
// surely don't want to get new defaults/settings during the _same_ requests, it
// could produce relatively strange behaviors
localCache = [[NSMutableDictionary alloc] init];
// We fire our timer that will cleanup cache entries