Search code examples
phpconfigurationprecompiling

PHP: optimum configuration storage?


My application gets configured via a lot of key/values (let's say 30.000 for instance)

I want to find the best deployment method for these configurations, knowing that I want to avoid DEFINEs to allow for runtime re-configuration.

I have thought of

  • pre-compiling them into an array via a php file
  • pre-compiling them into a tmpfs sqlite database
  • pre-compiling them into a memcached db

what are my options for

  • the best random access time to these configuration (memory is not an issue) ?
  • the best structured access time if i can break up these configuration into families like (network, i18n, ..)

Thanks Jerome


Solution

  • Well, if memory isn't an issue, just serialize an array to a file. There is absolutely no faster solution than this. You don't have the I/O and library overhead of SQLite, and you don't have the network overhead of memcached.

    But keep in mind, memory must really not be an issue. You'd be loading the entire 30,000 element array into memory at once, as opposed to using a database, where you could load them on an as-needed basis.

    To structure the settings, you could put each in its own file.

    But really, you should be using a database. That's what they're there for. I really question why you would need to worry about 30k settings..you might want to reconsider your application design.