开发者

searching for files from a single folder (knowing prefix) versus searching for files from multiple folders (knowing folder name)

开发者 https://www.devze.com 2022-12-18 11:47 出处:网络
I\'ve got a system in which users select a couple of options and receive an image based on those options. I\'m trying to combine multiple generated images(corresponding to those options) into the requ

I've got a system in which users select a couple of options and receive an image based on those options. I'm trying to combine multiple generated images(corresponding to those options) into the requested picture. 开发者_如何学CI'm trying to optimize this so that if, an image exists for a certain option (i.e. the file exists), then there's no need to compute it and we move on to the next step.

Should I store these images in different folders, where each folder is an option name? Should I store them in the same folder, adding a prefix corresponding to the option to each image? Should I store the filenames in a database and check there? Which way is faster to check a file for existence?

I'm using PHP on Linux, but I'm also interested if the answer varies if I change the programming language or the OS.


If you're going to be producing a lot of these images, it doesn't seem very scalable to keep them all in one flat directory. I would go with a hierarchy, which will make it a lot easier to manage.

It's always going to be quicker to check in a database than to check if a file exists though, so if speed is the primary concern, use a hierarchical folder structure and keep all the filenames in a database.

0

精彩评论

暂无评论...
验证码 换一张
取 消