/**
  * Store the given I2CE_MagicDataNode into mongodb
  * @param I2CE_MagicDataNode $node
  */
 public function store($node)
 {
     //first we need to see if it exists:
     $path = $node->getPath(false);
     $result = $this->mcoll->findOne(array(self::PATH => $path), array(self::PATH));
     if (!is_array($result) || count($result) == 0) {
         //does not exist
         $data = array(self::PATH => $path, self::TYPE => $node->getType(), self::VALUE => $node->getSaveValue(), self::CHILDREN => $node->getKeys(NULL, TRUE));
         if (!is_array($res = $this->mcoll->insert($data, array("safe" => true))) || array_key_exists('err', $res) && $res['err']) {
             I2CE::raiseError("Could not inset new node:" . print_r($res, true));
             return false;
         }
     } else {
         //it exists and we need to update
         $data = array(self::TYPE => $node->getType(), self::VALUE => $node->getSaveValue(), self::CHILDREN => $node->getKeys(NULL, TRUE));
         $newdata = array('$set' => $data);
         if (!is_array($res = $this->mcoll->update(array(self::PATH => $path), $newdata, array('safe' => true))) || array_key_exists('err', $res) && $res['err']) {
             I2CE::raiseError("Could not update existing node:" . print_r($res, true));
             return false;
         }
     }
     return true;
 }
 /**
  * Store the given I2CE_MagicDataNode into APC
  * @param I2CE_MagicDataNode $node
  * @returns boolean.  True on sucess
  */
 public function store($node)
 {
     $save_data = array('type' => $node->getType());
     if ($node->is_scalar()) {
         $save_data['value'] = $node->getSaveValue();
     } else {
         $save_data['value'] = null;
     }
     $children = $node->getKeys(null, true);
     if (count($children) > 0) {
         $save_data['children'] = $children;
     } else {
         $save_data['children'] = null;
     }
     if (!$this->memcached->set($this->getKey($node), $save_data, self::TIMEOUT)) {
         I2CE_MagicDataNode::raiseError("Error saving to Memcached " . $node->getPath() . " Type: " . $node->getType() . " Children: " . print_r($save_data['children'], true) . " Message: " . $this->memcached->getResultMessage() . " Stats: " . print_r($this->memcached->getStats(), true) . " Value: " . $save_data['value']);
         return false;
     } else {
         return true;
     }
 }