diff --git a/ChangeLog b/ChangeLog index 173fa0945..456aa897b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ 2011-07-15 Wolfgang Sourdeau + * 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 diff --git a/SoObjects/SOGo/SOGoCache.h b/SoObjects/SOGo/SOGoCache.h index f3d8a7b75..7f8fbb7fb 100644 --- a/SoObjects/SOGo/SOGoCache.h +++ b/SoObjects/SOGo/SOGoCache.h @@ -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 diff --git a/SoObjects/SOGo/SOGoCache.m b/SoObjects/SOGo/SOGoCache.m index 1e2962601..3cb184303 100644 --- a/SoObjects/SOGo/SOGoCache.m +++ b/SoObjects/SOGo/SOGoCache.m @@ -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