Initialise caches, always call before accessing self:: caches.
15275
protected static function init() {
        global $CFG;

        // Init only once per request/CLI execution, we ignore changes done afterwards.
        if (isset(self::$plugintypes)) {
            return;
        }

        if (defined('IGNORE_COMPONENT_CACHE') and IGNORE_COMPONENT_CACHE) {
            self::fill_all_caches();
            return;
        }

        if (!empty($CFG->alternative_component_cache)) {
            // Hack for heavily clustered sites that want to manage component cache invalidation manually.
            $cachefile = $CFG->alternative_component_cache;

            if (file_exists($cachefile)) {
                if (CACHE_DISABLE_ALL) {
                    // Verify the cache state only on upgrade pages.
                    $content = self::get_cache_content();
                    if (sha1_file($cachefile) !== sha1($content)) {
                        die('Outdated component cache file defined in $CFG->alternative_component_cache, can not continue');
                    }
                    return;
                }
                $cache = array();
                include($cachefile);
                self::$plugintypes      = $cache['plugintypes'];
                self::$plugins          = $cache['plugins'];
                self::$subsystems       = $cache['subsystems'];
                self::$parents          = $cache['parents'];
                self::$subplugins       = $cache['subplugins'];
                self::$classmap         = $cache['classmap'];
                self::$classmaprenames  = $cache['classmaprenames'];
                self::$filemap          = $cache['filemap'];
                return;
            }

            if (!is_writable(dirname($cachefile))) {
                die('Can not create alternative component cache file defined in $CFG->alternative_component_cache, can not continue');
            }

            // Lets try to create the file, it might be in some writable directory or a local cache dir.

        } else {
            // Note: $CFG->cachedir MUST be shared by all servers in a cluster,
            //       use $CFG->alternative_component_cache if you do not like it.
            $cachefile = "$CFG->cachedir/core_component.php";
        }

        if (!CACHE_DISABLE_ALL and !self::is_developer()) {
            // 1/ Use the cache only outside of install and upgrade.
            // 2/ Let developers add/remove classes in developer mode.
            if (is_readable($cachefile)) {
                $cache = false;
                include($cachefile);
                if (!is_array($cache)) {
                    // Something is very wrong.
                } else if (!isset($cache['version'])) {
                    // Something is very wrong.
                } else if ((float) $cache['version'] !== (float) self::fetch_core_version()) {
                    // Outdated cache. We trigger an error log to track an eventual repetitive failure of float comparison.
                    error_log('Resetting core_component cache after core upgrade to version ' . self::fetch_core_version());
                } else if ($cache['plugintypes']['mod'] !== "$CFG->dirroot/mod") {
                    // $CFG->dirroot was changed.
                } else {
                    // The cache looks ok, let's use it.
                    self::$plugintypes      = $cache['plugintypes'];
                    self::$plugins          = $cache['plugins'];
                    self::$subsystems       = $cache['subsystems'];
                    self::$parents          = $cache['parents'];
                    self::$subplugins       = $cache['subplugins'];
                    self::$classmap         = $cache['classmap'];
                    self::$classmaprenames  = $cache['classmaprenames'];
                    self::$filemap          = $cache['filemap'];
                    return;
                }
                // Note: we do not verify $CFG->admin here intentionally,
                //       they must visit admin/index.php after any change.
            }
        }

        if (!isset(self::$plugintypes)) {
            // This needs to be atomic and self-fixing as much as possible.

            $content = self::get_cache_content();
            if (file_exists($cachefile)) {
                if (sha1_file($cachefile) === sha1($content)) {
                    return;
                }
                // Stale cache detected!
                unlink($cachefile);
            }

            // Permissions might not be setup properly in installers.
            $dirpermissions = !isset($CFG->directorypermissions) ? 02777 : $CFG->directorypermissions;
            $filepermissions = !isset($CFG->filepermissions) ? ($dirpermissions & 0666) : $CFG->filepermissions;

            clearstatcache();
            $cachedir = dirname($cachefile);
            if (!is_dir($cachedir)) {
                mkdir($cachedir, $dirpermissions, true);
            }

            if ($fp = @fopen($cachefile.'.tmp', 'xb')) {
                fwrite($fp, $content);
                fclose($fp);
                @rename($cachefile.'.tmp', $cachefile);
                @chmod($cachefile, $filepermissions);
            }
            @unlink($cachefile.'.tmp'); // Just in case anything fails (race condition).
            self::invalidate_opcode_php_cache($cachefile);
        }
    }
1340422
private function initializeOnDemand()
    {
        if ($this->initialized === false) {

            $this->initialized = true;
            $this->cache = $this->cacheMapper->fetchAll();

            // Run garbage collection on each HTTP request
            $this->gc();
        }
    }
192656
def _initialize_uaa_cache(self):
        
        try:
            os.makedirs(os.path.dirname(self._cache_path))
        except OSError as exc:
            if exc.errno != errno.EEXIST:
                raise

        data = {}
        data[self.uri] = []

        return data
1239486
public static void initialize()
    {
        if (InfinispanCache.get().exists(Company.UUIDCACHE)) {
            InfinispanCache.get().<UUID, Company>getCache(Company.UUIDCACHE).clear();
        } else {
            InfinispanCache.get().<UUID, Company>getCache(Company.UUIDCACHE)
                            .addListener(new CacheLogListener(Company.LOG));
        }
        if (InfinispanCache.get().exists(Company.IDCACHE)) {
            InfinispanCache.get().<Long, Company>getCache(Company.IDCACHE).clear();
        } else {
            InfinispanCache.get().<Long, Company>getCache(Company.IDCACHE)
                            .addListener(new CacheLogListener(Company.LOG));
        }
        if (InfinispanCache.get().exists(Company.NAMECACHE)) {
            InfinispanCache.get().<String, Company>getCache(Company.NAMECACHE).clear();
        } else {
            InfinispanCache.get().<String, Company>getCache(Company.NAMECACHE)
                            .addListener(new CacheLogListener(Company.LOG));
        }
    }
470129
def set_memory_cache(self, results, key=None):
        """"""
        key = self.model.hash if key is None else key
        self.memory_cache[key] = results
233606
public function initializeObject()
    {
        if ($this->cache->has($this->cacheKey)) {
            $this->parsedData = $this->cache->get($this->cacheKey);
        } else {
            $this->parsedData = $this->parseFiles($this->sourcePaths);
            $this->parsedData = $this->resolveAliases($this->parsedData, '');
            $this->cache->set($this->cacheKey, $this->parsedData);
        }
    }
1331429
private void init() {
    host = DEFAULT_HOST;
    port = DEFAULT_PORT;
    database = DEFAULT_DATABASE;
    user = DEFAULT_USER;
    password = DEFAULT_PASSWORD;
    cachePreparedStatements = DEFAULT_CACHE_PREPARED_STATEMENTS;
    pipeliningLimit = DEFAULT_PIPELINING_LIMIT;
    sslMode = DEFAULT_SSLMODE;
  }
406573
public static void initialize()
    {
        if (InfinispanCache.get().exists(Consortium.UUIDCACHE)) {
            InfinispanCache.get().<UUID, Consortium>getCache(Consortium.UUIDCACHE).clear();
        } else {
            InfinispanCache.get().<UUID, Consortium>getCache(Consortium.UUIDCACHE)
                            .addListener(new CacheLogListener(Consortium.LOG));
        }
        if (InfinispanCache.get().exists(Consortium.IDCACHE)) {
            InfinispanCache.get().<Long, Consortium>getCache(Consortium.IDCACHE).clear();
        } else {
            InfinispanCache.get().<Long, Consortium>getCache(Consortium.IDCACHE)
                            .addListener(new CacheLogListener(Consortium.LOG));
        }
        if (InfinispanCache.get().exists(Consortium.NAMECACHE)) {
            InfinispanCache.get().<String, Consortium>getCache(Consortium.NAMECACHE).clear();
        } else {
            InfinispanCache.get().<String, Consortium>getCache(Consortium.NAMECACHE)
                            .addListener(new CacheLogListener(Consortium.LOG));
        }
    }
1119716
def _init(self, *args, **kwargs):
        
        self._init_attr('_deps', None)

        self._init_attr('_ban_optimize', False)
        self._init_attr('_engine', None)
        self._init_attr('_Expr__execution', None)

        self._init_attr('_need_cache', False)
        self._init_attr('_mem_cache', False)

        if '_id' not in kwargs:
            kwargs['_id'] = new_id()

        super(Expr, self)._init(*args, **kwargs)
219248
def init_cachedir(base=None):
    '''
    
    '''
    if base is None:
        base = __opts__['cachedir']
    needed_dirs = (base,
                   os.path.join(base, 'requested'),
                   os.path.join(base, 'active'))
    for dir_ in needed_dirs:
        if not os.path.exists(dir_):
            os.makedirs(dir_)
        os.chmod(base, 0o755)

    return base
1105976
def initialize_directories(self):
        """"""
        makedirs(self.config.source_index)
        makedirs(self.config.eggs_cache)
491681
public function init()
    {
        $this->db = \PHPDaemon\Clients\Mongo\Pool::getInstance($this->config->mongoclientname->value);
        $this->cache = \PHPDaemon\Clients\Memcache\Pool::getInstance($this->config->memcacheclientname->value);
        if (!isset($this->config->limitinstances)) {
            $this->log('missing \'limitInstances\' directive');
        }
    }
492090
protected function _initCache()
    {
        $this->bootstrap('project');

        $useCache = $this->getResource('project')->getCache();

        $cache       = null;
        $exists      = false;
        $cachePrefix = GEMS_PROJECT_NAME . '_';


        // Check if APC extension is loaded and enabled
        if (\MUtil_Console::isConsole() && !ini_get('apc.enable_cli') && $useCache === 'apc') {
            // To keep the rest readable, we just fall back to File when apc is disabled on cli
            $useCache = "File";
        }
        if ($useCache === 'apc' && extension_loaded('apc') && ini_get('apc.enabled')) {
            //Add path to the prefix as APC is a SHARED cache
            $cachePrefix .= md5(APPLICATION_PATH);
            $cacheBackendOptions = array('cache_id_prefix' => $cachePrefix);
            $cacheBackend = new \Gems\Cache\Backend\Apc($cacheBackendOptions);
            $exists = true;
        } else {
            $cacheBackend = 'File';
            $cacheDir = GEMS_ROOT_DIR . "/var/cache/";
            $cacheBackendOptions = array('cache_dir' => $cacheDir);
            if (!file_exists($cacheDir)) {
                if (@mkdir($cacheDir, 0777, true)) {
                    $exists = true;
                }
            } else {
                $exists = true;
            }
        }

        if ($exists && $useCache <> 'none') {
            /**
             * automatic_cleaning_factor disables automatic cleaning of the cache and should get rid of
             *                           random delays on heavy traffic sites with File cache. Apc does
             *                           not support automatic cleaning.
             */
            $cacheFrontendOptions = array('automatic_serialization' => true,
                                          'cache_id_prefix' => $cachePrefix,
                                          'automatic_cleaning_factor' => 0);

            $cache = \Zend_Cache::factory('Core', $cacheBackend, $cacheFrontendOptions, $cacheBackendOptions);
        } else {
            $cache = \Zend_Cache::factory('Core', 'Static', array('caching' => false), array('disable_caching' => true));
        }

        \Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
        \Zend_Translate::setCache($cache);
        \Zend_Locale::setCache($cache);

        return $cache;
    }
959498
public function init()
	{
		parent::init();
		$servers=$this->getServers();
		$cache=$this->getMemCache();
		if(count($servers))
		{
			foreach($servers as $server)
			{
				if($this->useMemcached)
					$cache->addServer($server->host,$server->port,$server->weight);
				else
					$cache->addServer($server->host,$server->port,$server->persistent,$server->weight,$server->timeout,$server->retryInterval,$server->status);
			}
		}
		else
			$cache->addServer('localhost',11211);
	}
625192
def init_cache():
    '''
    
    '''
    cache_obj = json.loads("{}")
    try:
        with open(CACHE_NAME, 'r') as cache_file:
            try:
                cache_obj = json.load(cache_file)
            except ValueError:
                print("The cache file seems to be empty, starting with flushed cache")
    except IOError:
        print("The cache file seems to be empty, starting with flushed cache")

    print("Loaded JSON cache")

    return cache_obj
866204
public static void initialize()
    {
        if (InfinispanCache.get().exists(SystemConfiguration.UUIDCACHE)) {
            InfinispanCache.get().<UUID, SystemConfiguration>getCache(SystemConfiguration.UUIDCACHE).clear();
        } else {
            InfinispanCache.get().<UUID, SystemConfiguration>getCache(SystemConfiguration.UUIDCACHE)
                            .addListener(new CacheLogListener(SystemConfiguration.LOG));
        }
        if (InfinispanCache.get().exists(SystemConfiguration.IDCACHE)) {
            InfinispanCache.get().<Long, SystemConfiguration>getCache(SystemConfiguration.IDCACHE).clear();
        } else {
            InfinispanCache.get().<Long, SystemConfiguration>getCache(SystemConfiguration.IDCACHE)
                            .addListener(new CacheLogListener(SystemConfiguration.LOG));
        }
        if (InfinispanCache.get().exists(SystemConfiguration.NAMECACHE)) {
            InfinispanCache.get().<String, SystemConfiguration>getCache(SystemConfiguration.NAMECACHE).clear();
        } else {
            InfinispanCache.get().<String, SystemConfiguration>getCache(SystemConfiguration.NAMECACHE)
                            .addListener(new CacheLogListener(SystemConfiguration.LOG));
        }

        SystemConfiguration.ENCRYPTOR = new StandardPBEStringEncryptor();
        SystemConfiguration.ENCRYPTOR.setConfig(SystemConfiguration.getPBEConfig());
    }
619911
def init_extension(self, app):
        """"""
        app.config.setdefault('CACHE_VERSION', '0')
        app.config.setdefault('CACHE_PREFIX', 'r')
        app.config.setdefault('CACHE_BACKEND', 'rio.exts.flask_cache.NullBackend')
        app.config.setdefault('CACHE_BACKEND_OPTIONS', {})