'Get the indicated index.
"dir" is the dir path this index represents.
"index_name" is the name of the index.
"default" (default None) indicate the value to return for
the index if the index doesn\'t exist. If not set (or
None) then an OSError is raised if the index doesn\'t exist.
The index is loaded from a pickle on disk, if necessary, put
into the cache system, and returned.
This must be called with the lock held.'

def load_index(self, dir, index_name, default=None):

    self._acquire_lock()
    try:
        dbsubpath = join(self.db.dhash_from_dir(dir), index_name)
        now = time.time()
        if (dbsubpath in self._index_and_atime_from_dbsubpath):
            log.debug("cache-read:    load    %s    index    '%s'", self.lang, dbsubpath)
            self._index_and_atime_from_dbsubpath[dbsubpath][1] = now
            return self._index_and_atime_from_dbsubpath[dbsubpath][0]
        log.debug("fs-read:    load    %s    index    '%s'", self.lang, dbsubpath)
        dbpath = join(self.base_dir, dbsubpath)
        index = self.db.load_pickle(dbpath, default)
        if (index_name == 'toplevelname_index'):
            index = self.toplevelname_index_class(index)
        self._index_and_atime_from_dbsubpath[dbsubpath] = [index, now]
        return index
    finally:
        self._release_lock()
