0

I'm using Mage_Core_Model_Config() to store and read some persistent data I need. I use it like this:

// init model config
$this->_config = new Mage_Core_Model_Config();

// set value
$this->_config->saveConfig($key, $value);

// get value
return Mage::getStoreConfig($key);

However, I noticed that even if I set new value, when I get it the data only update every couple of hours, and that's probably due to Magento cache. But I need my data to be immediate and change every couple of minutes.

Since I'm writing an extension I can't just turn the cache off at my clients servers.

So how do I put non-cacheable data in the config? or how do I force magento to drop the cache for a specific key?

If that's not possible, I'd also appreciate alternative suggestions to use something else instead of Mage_Core_Model_Config. All I need is basic key-value persistent storage mechanism.

Thanks!

Edit: is custom variables a good choice for me requirements?

5
  • Are you really updating configuration values every few hours or is that any other data you are working with? If you are updating data, then I suggest you create you own database table(s) to save it there. Commented Jan 3, 2016 at 10:45
  • no its not really configuration, I just need a fast and easy to use key-value storage. but I do need it to update every couple of minutes. would you recommend custom variables? or database?
    – Ronen Ness
    Commented Jan 3, 2016 at 11:08
  • 1
    Better use your own table in the database for this. Commented Jan 3, 2016 at 11:29
  • I would agree with Anna, using your own table makes much better sense. There is an option, I have never used, but I have seen it done, Core Variable. Honestly, I would assume its not what you need, but if you do not want to have a custom table, this MAY offer what you need. Commented Jan 3, 2016 at 16:52
  • Thanks Anna, Russell. I ended up using plain files as a (maybe) temporary solution. I consider this solution temporary but if I see it gives me no problems maybe I'll just keep it. its kidna straight-forward and efficient.
    – Ronen Ness
    Commented Jan 3, 2016 at 17:08

1 Answer 1

1

So how do I put non-cacheable data in the config? or how do I force magento to drop the cache for a specific key?

You don't. Configuration is someting which changes from time to time, but not every couple of minutes.

As Anna said:

Are you really updating configuration values every few hours or is that any other data you are working with? If you are updating data, then I suggest you create you own database table(s) to save it there.

The alternative would be to clear the cache after each write, but this doesn't make sense.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.