简体   繁体   中英

Save Properties File MOST EFFICIENT

Which of these ways is better (faster, less storage)?

  1. Save thousands of xyz.properties in every file — about 30 keys/values
  2. One .properties file with all the data in it — about 30,000 keys/values

打开和关闭1000个文件是操作系统的主要开销,因此,最好使用一个大文件。

I think there are two aspects here:

  1. As Guenther has correctly pointed out, dealing with files comes with overhead . You need "file handles"; and possible other data structures that deal with files; so there might many different levels where having one huge file is better than having many small files.
  2. But there is also "maintainability". Meaning: from a developers point of view, dealing with a property file that contains 30 K key/values is something you really don't want to get into. If everything is in one file, you have to constantly update (and deploy) that one huge file. One change; and the whole file needs to go out. Will you have mechanisms in place that allow for "run-time" reloading of properties; or would that mean that your application has to shut down? And how often will it happen that you have duplicates in that large file; or worse: you put a value for property A on line 5082, and then somebody doesn't pay attention and overrides property A on line 29732. There are many things that can go wrong; just because of having all that stuff in one file; unable to be digested by any human being anymore! And rest assured: debugging something like that will be hard .

I just gave you some questions to think about; so you might want to step back to give more requirements from your end.

In any way; you might want to look into a solution where developers deal with the many small property file (you know, like one file per functionality). And then you use tooling to build that one large file used in the production environment.

Finally: if your application really needs 30K properties; then you should very much more worry about the quality of your product. In my eyes, this isn't a design "smell"; it sounds like a design fetidness. Meaning: no reasonably application should require 30K properties to function on.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM