Looking at LRUCache tests, I've found this:
testFibonacci
������ "After an idea by Jan Vrany.
������ Recursively enter the cache and its access protection"
������
������ | fibCache |
������ fibCache := self newCache.
������ fibCache
������ ������ maximumWeight: 32;
������ ������ beThreadSafe;
������ ������ factory: [ :key |
������ ������ ������ key < 2
������ ������ ������ ������ ifTrue: [ key ]
������ ������ ������ ������ ifFalse: [ (fibCache at: key - 1) + (fibCache at: key - 2) ] ].
������ self assert: (fibCache at: 40) equals: 102334155
the factory thing basically solves the problem.
Is there more docs about the caching somewhere? I read the code, comments, and unit tests but still, will value an explanation.
Keying by object works, but with symbols, it isn't behaving. I think I miss something here.
Is the cache size set at a given limit?
I see keyIndex is Dictionary new. What if I do have a lot of keys? Is the dictionary being copied over and over to get to the right size?
Phil
Phil
Phil