/**
  * Loads user keys into the cache.
  *
  * @version 1.0
  * @since 1.0
  *
  * @param int/array $user_id | Single user id as int. Multiple user id's as array of int.
  * @param int/array $key_id | Single key id as int. Multiple key ids as array of int.
  * @return bool | False on failure. True on success.
  */
 public function load($user_id, $key_id = null, $skip_load = false)
 {
     global $fox;
     $db = new FOX_db();
     $args = array();
     if ($user_id) {
         $args[] = array("col" => "user_id", "op" => "=", "val" => $user_id);
     }
     if ($key_id) {
         $args[] = array("col" => "key_id", "op" => "=", "val" => $key_id);
     }
     $columns = array("mode" => "include", "col" => array("user_id", "key_id"));
     $ctrl = array("format" => "array_key_array_grouped", "key_col" => array("user_id", "key_id"));
     try {
         $db_result = $db->runSelectQuery(self::$struct, $args, $columns, $ctrl);
     } catch (FOX_exception $child) {
         throw new FOX_exception(array('numeric' => 1, 'text' => "DB select exception", 'data' => array("args" => $args, "columns" => $columns, "ctrl" => $ctrl), 'file' => __FILE__, 'line' => __LINE__, 'method' => __METHOD__, 'child' => $child));
     }
     // When the function is called with specific keys to look for, if a user doesn't
     // have that key, we can add that information to the cache. This saves a query
     // the next time the key is requested.
     if ($db_result) {
         if ($key_id) {
             if (!is_array($user_id)) {
                 $user_id = array($user_id);
             }
             if (!is_array($key_id)) {
                 $key_id = array($key_id);
             }
             $all_ok = true;
             foreach ($user_id as $user) {
                 // Load the persistent cache record for the user_id into the class's cache array
                 if (!$skip_load) {
                     $this->cache[$user] = $fox->cache->get("FOX_uKeyRing", $user);
                 }
                 foreach ($key_id as $key) {
                     if (FOX_sUtil::valExists($key, $db_result[$user])) {
                         $this->cache[$user]["keys"][$key] = true;
                     } else {
                         $this->cache[$user]["keys"][$key] = false;
                     }
                 }
                 // Save the updated persistent cache record for the user_id
                 $cache_ok = $fox->cache->set("FOX_uData", $user, $this->cache[$user]);
                 if (!$cache_ok) {
                     $all_ok = false;
                 }
             }
             return $all_ok;
         } else {
             // If the function is called without $key_id set, all of the keys for each user will be added
             // to the cache. At this point we can unset all of the user's "false" keys because we know the
             // list of keys is authoratative (if it's not in the array, they don't have the key).
             $all_ok = true;
             foreach ($db_result as $user => $keys) {
                 unset($this->cache[$user]);
                 $this->cache[$user]["all_cached"] = true;
                 foreach ($keys as $key) {
                     $this->cache[$user]["keys"][$key] = true;
                 }
                 // Save the updated persistent cache record for the user_id
                 $cache_ok = $fox->cache->set("FOX_uData", $user, $this->cache[$user]);
                 if (!$cache_ok) {
                     $all_ok = false;
                 }
             }
             return $all_ok;
         }
     } else {
         return false;
     }
 }