1

I'm a newbie with XCache and I'm trying to use this feature for have an editable configuration over the air in my application.

So I need to store some data, for doing this I did:

class Settings
{
    private $_config = array();

    function __construct()
    {
        $file = 'config.php'; //return $config content
        require_once $file;

        $this->_config = $config;

        foreach($config as $item => $value)
        {
            if(!xcache_isset($item))
            {
                xcache_set($item, $value);
            }
        }
    }
}

Unfortunately today the official site seems down, so I can't follow the documentation to check if I did something wrong.

I've created also two method:

public static function setItem($name, $value)
{
    xcache_set($name, $value);
}

public static function getItem($name)
{
    return xcache_get($name);
}

now getItem after 15/20 minute can't get the key value. Why?

UPDATE

Okay, the problem it's when an header('Location..) is called. Infact if I do a redirection I lost the value stored in cache, anyone know why?

user3287550
  • 363
  • 4
  • 12

1 Answers1

0

As the name implies, XCache is a cache, not a database. Values that you store in the cache may be purged without warning if space is needed for other data, and will be lost entirely when the web server is restarted. It's not an appropriate place to store configuration information.

I can't say for certain why you're seeing values become unavailable after a redirect, though. That shouldn't happen.