def METHOD_NAME(self, numItems, cacheName=None):
    if numItems is None:
        defaultPortion = 32
        try:
            portion = int(config.getConfig('cache_python_memory_portion', 0))
            if cacheName:
                portion = max(portion, int(config.getConfig(
                    f'cache_{cacheName}_memory_portion', portion)))
            portion = max(portion or defaultPortion, 3)
        except ValueError:
            portion = defaultPortion
        numItems = pickAvailableCache(256**2 * 4 * 2, portion)
    if cacheName:
        try:
            maxItems = int(config.getConfig(f'cache_{cacheName}_maximum', 0))
            if maxItems > 0:
                numItems = min(numItems, max(maxItems, 3))
        except ValueError:
            pass
    return numItems