Welcome Guest, Not a member yet? Register   Sign In
Configuration Files
#1

[eluser]garymardell[/eluser]
Hey,

Well this started as a question of how to do it, but i now think that i know how to get a config from file and save the values back to the file just by writing this thread.

However i was wondering if anyone had implemented a class to save an updated item permanently back to the file.
#2

[eluser]überfuzz[/eluser]
Exactly what would you like to chenge around in the config file..? Save dynamic stuff in the database and leave the config file more or less as it is when you launch the site.
#3

[eluser]Twisted1919[/eluser]
Maybe this is a start ?
http://ellislab.com/forums/viewthread/133342/
#4

[eluser]garymardell[/eluser]
Thanks for the link, the concept is good. May take a little work as i don't really wish to use ftp to achieve the same thing. I pretty much just want to overwrite the config class to get the data from the files as it does, but then also setting data to write it to the file rather than dynamically.
#5

[eluser]Jondolar[/eluser]
I recommend what überfuzz said. Don't write your config changes to a file. Write them to a database table. Static configuration settings can go into a file such as that are usually only changed during initial installation. Offering an administrator options to change settings should only be done for settings that would change during the life of the installation IMO.
#6

[eluser]garymardell[/eluser]
Well i was thinking i would be storing them in a text file to act as caching, completely forgetting about the db caching that i could enable. Thanks guys, this thread worked it all out for me i think unless there is anything else to eat. Now to make a class to piece it all together.

Edit: Erm now got a new question really. The problem i face is that after reading the caching guide for database queries is that it works on a per url basis. Where as i want it be global query as any single page might need access to the result.

Is there a way to either store the information in the database and cache it or back to saving it to a file. Which is best option now? I don't really want to be making a query every page load that i don't need to be doing.
#7

[eluser]jedd[/eluser]
[quote author="garymardell" date="1259730823"]
Well i was thinking i would be storing them in a text file to act as caching, completely forgetting about the db caching that i could enable.
[/quote]

Databases will cache better than file systems, as a general rule

Quote:Edit: Erm now got a new question really. The problem i face is that after reading the caching guide for database queries is that it works on a per url basis. Where as i want it be global query as any single page might need access to the result.

Is there a way to either store the information in the database and cache it or back to saving it to a file. Which is best option now? I don't really want to be making a query every page load that i don't need to be doing.

You appear to be confusing CI caching with database caching - they operate at different levels. If you're using MySQL, then the database will cache every query and if the same (it has to be precisely the same) query comes through again it will use the cached result.

In general terms - you should code now, optimise later.

And you should assume that people that write operating systems, file systems and databases really know what they're doing - because they usually do.
#8

[eluser]garymardell[/eluser]
I was reading http://ellislab.com/codeigniter/user-gui...ching.html

"For example, let's say you have a controller called blog with a function called comments that contains three queries. The caching system will create a cache folder called blog+comments, into which it will write three cache files.

If you use dynamic queries that change based on information in your URI (when using pagination, for example), each instance of the query will produce its own cache file. It's possible, therefore, to end up with many times more cache files than you have queries."

I never questions that they wouldn't know what they were doing. Ah well i guess i will just write it, it was more from the code design point of view i wanted to know what would be best.
#9

[eluser]jedd[/eluser]
Oh, my apologies - I read your earlier message too fast and thought you were talking about the general web caching ([url="/user_guide/general/caching.html"]described here[/url]). Sorry about that.

I don't know enough about other DB engines (I don't know much about MySQL, but that aside .. Smile but this seems to be a db-agnostic approach to caching. As you observe, you could end up with quite a few files floating about - no biggy, as you can tidy them, but you do then have to wear the cost of garbage collection.

What I do know about MySQL is that it caches select queries, too. I would expect those cache items would never be written to disk - it presumably allocates a lump of memory to the task. (You should probably read up on this if you're curious - I'm speculating a bit here, and partly remembering bits of a High Performance MySQL text I read ages back.) In either case I suspect that MySQL would provide comparable cache with less overhead. I'd expect the other common DB types had also optimised for this kind of scenario.

Where your DB is on a different box - across a relatively low speed link - you might get some benefit from this CI DB caching. Again, if you were using MySQL, there are other ways to improve your performance. But .. this is getting into pretty serious optimisation considerations for something that isn't, at the moment, looking like it's going to perform badly ... (or is it? Wink
#10

[eluser]garymardell[/eluser]
Thanks for the information, ill look into it as well about MySQL caching.
I'm not really trying to optimize now, just look for ways to improve the code for the future.
If it was something to implement quickly that was suggested i would have gone a head and done it.




Theme © iAndrew 2016 - Forum software by © MyBB