AD73BE4B06CF88BF00226A2D,
AD071D1206CD2BCB00A9EEF4,
AD071D1306CD2BCB00A9EEF4,
+ AD255F390735B15E00D424E6,
+ AD255F3A0735B15E00D424E6,
ADA6333607140E0D0058C21C,
);
isa = PBXGroup;
tabWidth = 8;
usesTabs = 1;
};
+ AD255F390735B15E00D424E6 = {
+ fileEncoding = 5;
+ indentWidth = 2;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = SOGoLRUCache.h;
+ refType = 4;
+ sourceTree = "<group>";
+ tabWidth = 2;
+ usesTabs = 0;
+ };
+ AD255F3A0735B15E00D424E6 = {
+ fileEncoding = 5;
+ indentWidth = 2;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.objc;
+ path = SOGoLRUCache.m;
+ refType = 4;
+ sourceTree = "<group>";
+ tabWidth = 2;
+ };
AD2C74A1071A9FF70087E027 = {
fileEncoding = 5;
isa = PBXFileReference;
#import <Foundation/Foundation.h>
+@class SOGoLRUCache;
@interface AgenorUserManager : NSObject
{
+ SOGoLRUCache *cnCache;
+ SOGoLRUCache *serverCache;
}
+ (id)sharedUserManager;
#include "AgenorUserManager.h"
#include <NGLdap/NGLdap.h>
-
+#include "SOGoLRUCache.h"
@interface AgenorUserManager (PrivateAPI)
- (NGLdapConnection *)ldapConnection;
- (id)init {
self = [super init];
if(self) {
+ self->serverCache = [[SOGoLRUCache alloc] initWithCacheSize:10000];
+ self->cnCache = [[SOGoLRUCache alloc] initWithCacheSize:10000];
}
return self;
}
- (void)dealloc {
+ [self->serverCache release];
+ [self->cnCache release];
[super dealloc];
}
}
- (void)_cacheCN:(NSString *)_cn forUID:(NSString *)_uid {
+ [self->cnCache addObject:_cn forKey:_uid];
}
- (NSString *)_cachedCNForUID:(NSString *)_uid {
- return nil;
+ return [self->cnCache objectForKey:_uid];
}
- (void)_cacheServer:(NSString *)_server forUID:(NSString *)_uid {
+ [self->serverCache addObject:_server forKey:_uid];
}
- (NSString *)_cachedServerForUID:(NSString *)_uid {
- return nil;
+ return [self->serverCache objectForKey:_uid];
}
+2004-11-01 Marcus Mueller <znek@mulle-kybernetik.com>
+
+ * v0.9.25
+
+ * SOGoLRUCache.[hm]: new class providing a generic cache for
+ objects used in SOGo. The cache is a LRU cache using a use count
+ to determined which objects are accessed most/least.
+
+ * AgenorUserManager.[hm]: uses SOGoLRUCache to cache CN's and
+ Servers.
+
2004-10-20 Marcus Mueller <znek@mulle-kybernetik.com>
* AgenorUserManager.[hm]: slightly changed the interface for retrieving
# GNUstep Makefile
include $(GNUSTEP_MAKEFILES)/common.make
+include ../SOGo/Version
include ./Version
LIBRARY_NAME = libSOGoLogic
SOGoAppointment.h \
SOGoAppointmentICalRenderer.h \
AgenorUserManager.h \
+ SOGoLRUCache.h \
NSString+iCal.h
libSOGoLogic_OBJC_FILES += \
SOGoAppointment.m \
SOGoAppointmentICalRenderer.m \
+ SOGoLRUCache.m \
AgenorUserManager.m \
-include GNUmakefile.preamble
--- /dev/null
+/*
+ Copyright (C) 2000-2004 SKYRIX Software AG
+
+ This file is part of OGo
+
+ OGo is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with OGo; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+ */
+// $Id$
+
+
+#ifndef __SOGoLRUCache_H_
+#define __SOGoLRUCache_H_
+
+
+#import <Foundation/Foundation.h>
+
+
+@interface SOGoLRUCache : NSObject
+{
+ unsigned size;
+ NSMutableDictionary *entries;
+}
+
+- (id)initWithCacheSize:(unsigned)_size;
+
+- (void)addObject:(id)_obj forKey:(id)_key;
+- (id)objectForKey:(id)_key;
+
+@end
+
+#endif /* __SOGoLRUCache_H_ */
--- /dev/null
+/*
+ Copyright (C) 2000-2004 SKYRIX Software AG
+
+ This file is part of OGo
+
+ OGo is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with OGo; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+ */
+// $Id$
+
+
+#import "SOGoLRUCache.h"
+#import "common.h"
+
+@interface SOGoLRUCacheItem : NSObject
+{
+ id object;
+ unsigned useCount;
+}
+
+- (id)initWithObject:(id)_obj;
+- (id)object;
+
+- (unsigned)useCount;
+
+@end
+
+@implementation SOGoLRUCacheItem
+
+- (id)initWithObject:(id)_obj {
+ self = [super init];
+ if(self) {
+ ASSIGN(self->object, _obj);
+ self->useCount = 1;
+ }
+ return self;
+}
+
+- (id)object {
+ self->useCount++;
+ return self->object;
+}
+
+- (unsigned)useCount {
+ return self->useCount;
+}
+
+@end
+
+@implementation SOGoLRUCache
+
+- (id)initWithCacheSize:(unsigned)_size {
+ self = [super init];
+ if(self) {
+ self->size = _size;
+ self->entries = [[NSMutableDictionary alloc] initWithCapacity:_size];
+ }
+ return self;
+}
+
+- (void)dealloc {
+ [self->entries release];
+ [super dealloc];
+}
+
+- (void)addObject:(id)_obj forKey:(id)_key {
+ SOGoLRUCacheItem *item;
+
+ NSAssert(_obj, @"Attempt to insert nil object!");
+
+ if([self->entries count] >= self->size) {
+ /* need to find minimum and get rid of it */
+ NSEnumerator *keyEnum;
+ SOGoLRUCacheItem *item;
+ id key, leastUsedItemKey;
+ unsigned minimumUseCount = INT_MAX;
+
+ keyEnum = [self->entries keyEnumerator];
+ while((key = [keyEnum nextObject])) {
+ item = [self->entries objectForKey:key];
+ if([item useCount] < minimumUseCount) {
+ minimumUseCount = [item useCount];
+ leastUsedItemKey = key;
+ }
+ }
+ [self->entries removeObjectForKey:leastUsedItemKey];
+ }
+ item = [[SOGoLRUCacheItem alloc] initWithObject:_obj];
+ [self->entries setObject:item forKey:_key];
+ [item release];
+}
+
+- (id)objectForKey:(id)_key {
+ SOGoLRUCacheItem *item;
+
+ item = [self->entries objectForKey:_key];
+ if(!item)
+ return nil;
+ return [item object];
+}
+
+@end
# Version file
-SUBMINOR_VERSION:=24
+SUBMINOR_VERSION:=25
# v0.9.23 requires NGiCal v4.3.32
# v0.9.18 requires NGExtensions v4.3.123