Sunday, February 28, 2010

Re: configuration and datasource

Hi

I would store the constants in the database but cache the query.
Here's an example

function getSettings($refresh = false) {
if ($refresh || !$settings = Cache::read('settings')) {
$settings = $this->find('list');
Cache::write('settings', $settings);
}
return $settings;
}

That will make sure that your db query is cached, so you won't have
the db overhead on every action. You'll just need to ensure that you
call a refreshed version of the settings table on every cud operation
to ensure that the data returned is up to date.

On Mar 1, 5:14 am, Roey <roeygr...@gmail.com> wrote:
> Hello all,
> My cakephp application uses a few custom configuration constants which
> I load from a configuration file.
> I would like to have some of the users to be able to change the
> settings of these constants.
> My first idea was to use a database table  which will contain these
> configuration constants, but then I thought that every call to every
> url would also create an extra call to a certain db table to fetch
> these config constants.
> I thought of another option which is creating a datasource which will
> be mapped to a configuraion file so when an update will be needed,
> this file will be re-written.
> Is it a good idea?
> How can I expose my configuration constants to be changed by some
> users without loosing performance ? The database is constantly being
> read and I don't want to add another read/write operation to it...
> Thanks very much,
> Roey

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: