mirror of
https://github.com/gnustep/libs-sqlclient.git
synced 2025-02-21 02:41:07 +00:00
Fix error in keeping track of cache size
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@21736 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2334458095
commit
ee9f3f4764
2 changed files with 8 additions and 10 deletions
14
SQLClient.m
14
SQLClient.m
|
@ -2401,10 +2401,8 @@ static void removeItem(SQLCItem *item, SQLCItem **first)
|
|||
lifetime: (unsigned)lifetime
|
||||
{
|
||||
SQLCItem *item;
|
||||
unsigned maxObjects = [self maxObjects];
|
||||
unsigned maxSize = [self maxSize];
|
||||
unsigned newSize = [self currentSize];
|
||||
unsigned newObjects = [self currentObjects];
|
||||
unsigned maxObjects = my->maxObjects;
|
||||
unsigned maxSize = my->maxSize;
|
||||
unsigned addObjects = (anObject == nil ? 0 : 1);
|
||||
unsigned addSize = 0;
|
||||
|
||||
|
@ -2412,10 +2410,10 @@ static void removeItem(SQLCItem *item, SQLCItem **first)
|
|||
if (item != nil)
|
||||
{
|
||||
removeItem(item, &my->first);
|
||||
newObjects--;
|
||||
my->currentObjects--;
|
||||
if (my->maxSize > 0)
|
||||
{
|
||||
newSize -= item->size;
|
||||
my->currentSize -= item->size;
|
||||
}
|
||||
NSMapRemove(my->contents, (void*)aKey);
|
||||
}
|
||||
|
@ -2452,8 +2450,8 @@ static void removeItem(SQLCItem *item, SQLCItem **first)
|
|||
item->size = addSize;
|
||||
NSMapInsert(my->contents, (void*)item->key, (void*)item);
|
||||
appendItem(item, &my->first);
|
||||
my->currentObjects = newObjects;
|
||||
my->currentSize = newSize;
|
||||
my->currentObjects += addObjects;
|
||||
my->currentSize += addSize;
|
||||
RELEASE(item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -234,7 +234,7 @@ main()
|
|||
r1 = [db cache: 1 query: @"select * from xxx", nil];
|
||||
NSCAssert([r0 lastObject] == [r1 lastObject], @"Cache failed");
|
||||
sleep(1);
|
||||
records = [db query: @"select * from xxx", nil];
|
||||
records = [db cache: 1 query: @"select * from xxx", nil];
|
||||
NSCAssert([r0 lastObject] != [records lastObject], @"Lifetime failed");
|
||||
|
||||
[db execute: @"drop table xxx", nil];
|
||||
|
@ -258,7 +258,7 @@ main()
|
|||
}
|
||||
}
|
||||
|
||||
NSLog(@"Records - %@", records);
|
||||
NSLog(@"Records - %@", [SQLCache class]);
|
||||
}
|
||||
|
||||
RELEASE(pool);
|
||||
|
|
Loading…
Reference in a new issue