Monotone-Parent: dc1a04dbd8c664b75c03181a48283724ed5866b2

Monotone-Revision: 509161891d714328d4a536f4225b69b69c8bf263

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2011-07-15T20:30:39
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2011-07-15 20:30:39 +00:00
parent 792fb895f7
commit c6bc85973d
3 changed files with 36 additions and 17 deletions

View File

@@ -6,6 +6,9 @@
2011-07-15 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/SOGo/SOGoCache.m (-disableRequestsCache): new method
that adds the ability to not put requests object in the cache.
* OpenChange/MAPIStoreDraftsAttachment.m: removed useless class.
* OpenChange/MAPIStoreMessage.m (-createAttachment): moved method

View File

@@ -44,6 +44,7 @@
NSMutableDictionary *localCache;
NSMutableDictionary *imap4Connections;
NSMutableDictionary *cache;
BOOL requestsCacheEnabled;
NSMutableDictionary *users;
NSMutableDictionary *groups;
float cleanupInterval;
@@ -52,6 +53,8 @@
+ (SOGoCache *) sharedCache;
- (void) disableRequestsCache;
- (void) killCache;
- (void) registerObject: (id) object

View File

@@ -86,18 +86,6 @@ static memcached_st *handle = NULL;
return sharedCache;
}
- (void) killCache
{
[cache removeAllObjects];
[imap4Connections removeAllObjects];
// This is essential for refetching the cached values in case something has changed
// accross various sogod processes
[users removeAllObjects];
[groups removeAllObjects];
[localCache removeAllObjects];
}
- (id) init
{
SOGoSystemDefaults *sd;
@@ -105,6 +93,7 @@ static memcached_st *handle = NULL;
if ((self = [super init]))
{
cache = [[NSMutableDictionary alloc] init];
requestsCacheEnabled = YES;
users = [[NSMutableDictionary alloc] init];
groups = [[NSMutableDictionary alloc] init];
imap4Connections = [[NSMutableDictionary alloc] init];
@@ -160,6 +149,23 @@ static memcached_st *handle = NULL;
[super dealloc];
}
- (void) disableRequestsCache
{
requestsCacheEnabled = NO;
}
- (void) killCache
{
[cache removeAllObjects];
[imap4Connections removeAllObjects];
// This is essential for refetching the cached values in case something has changed
// accross various sogod processes
[users removeAllObjects];
[groups removeAllObjects];
[localCache removeAllObjects];
}
- (NSString *) _pathFromObject: (SOGoObject *) container
withName: (NSString *) name
{
@@ -193,7 +199,7 @@ static memcached_st *handle = NULL;
{
NSString *fullPath;
if (object && name)
if (requestsCacheEnabled && object && name)
{
[self registerObject: container
withName: [container nameInContainer]
@@ -212,7 +218,7 @@ static memcached_st *handle = NULL;
{
NSString *fullPath;
if (name)
if (requestsCacheEnabled && name)
{
fullPath = [self _pathFromObject: container
withName: name];
@@ -224,11 +230,18 @@ static memcached_st *handle = NULL;
inContainer: (SOGoObject *) container
{
NSString *fullPath;
id cacheObject;
fullPath = [self _pathFromObject: container
withName: name];
if (requestsCacheEnabled)
{
fullPath = [self _pathFromObject: container
withName: name];
cacheObject = [cache objectForKey: fullPath];
}
else
cacheObject = nil;
return [cache objectForKey: fullPath];
return cacheObject;
}
- (void) registerUser: (SOGoUser *) user