Flat or nested directory structure for image cache?

My Mac application stores a collection of objects (with basic data), each of which has a cover art and to which I assign a UUID when I create it. I originally stored the covers as a field in my master data store, but recently I began to store them on disk in the file system.

First, I save the covers in a flat directory using the UUID to name the file, as shown below. This gives me an O (1) sample, since I know exactly where to look.

...
/.../Covers/3B723A52-C228-4C5F-A71C-3169EBA33677.jpg
/.../Covers/6BEC2FC4-B9DA-4E28-8A58-387BC6FF8E06.jpg
...

I looked at how other applications handle this task, and noticed a layered diagram, as shown below (for example). This can be implemented during O (1).

...
/.../Covers/A/B/3B723A52-C228-4C5F-A71C-3169EBA33677.jpg
/.../Covers/C/D/6BEC2FC4-B9DA-4E28-8A58-387BC6FF8E06.jpg
...

? X ? - ? , , , .

+3
3

( HFS +) .

ISP, ( 90k + ). . , , , UUID, , :

/.../Covers/3B/72/3B723A52-C228-4C5F-A71C-3169EBA33677.jpg
/.../Covers/6B/EC/6BEC2FC4-B9DA-4E28-8A58-387BC6FF8E06.jpg

, , , , . UUID , .

+3

, , , , ( FS ).

+2

, , , , .

. NTFS Windows XP , , .

+2

All Articles