Jump to content

ips_CacheRegistry -> getCache/_loadCaches


teraßyte

Recommended Posts

I am in the process of converting the global shoutbox and I've come across an issue with the caches.


In IPB 2.3 was possible to use init_load_cache to load an array of caches at once but now in IPB 3 this is not possible anymore, the only way is to use $this->cache->getCache('cache_name') but in this way I need to use 3 different queries to load 3 caches.

A quick solution would be to change the function _loadCache from private to public so everyone can access it or update the function getCache to support an array of caches.

Link to comment
Share on other sites

I was hoping that you implement this small change for 3.0.0 :(


Actually I have already rewritten the function on my own just for fun lol

    static public function getCache( $keys )

      {

          if ( is_string( $keys ) )

          {

              if ( ! in_array( $keys, array_keys( self::$data_store ) ) )

              {

                  self::_loadCaches( array( $keys ) );

              }


              return self::$data_store[ $keys ];

          }

          elseif ( is_array( $keys ) && count( $keys ) )

          {

              $toLoad = array();


              foreach( $keys as $key )

              {

                  if ( ! in_array( $key, array_keys( self::$data_store ) ) )

                  {

                      $toLoad[] = $key;

                  }

              }


              self::_loadCaches( $toLoad );


              return TRUE;

          }


          return FALSE;

      }
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...