Remove items from cache matching URLs.

        Return the number of items removed.
326828
def evict(cls, urls):
        
        if isinstance(urls, text_type):
            urls = [urls]
        urls = set(normalize_url(url) for url in urls)
        retval = 0
        with cls.ca_lock:
            for key in list(cls.cache):
                if key[0] in urls:
                    retval += 1
                    del cls.cache[key]
                    del cls.timeouts[key]
        return retval
423068
def delete(cls, resources, background=False, force=False):
        """"""
        if not isinstance(resources, (list, tuple)):
            resources = [resources]

        ifaces = []
        for item in resources:
            try:
                ip_ = cls.info(item)
            except UsageError:
                cls.error("Can't find this ip %s" % item)

            iface = Iface.info(ip_['iface_id'])
            ifaces.append(iface['id'])

        return Iface.delete(ifaces, background)
1123131
def delete(self):
        

        if not self.id:
            return
        if not self._loaded:
            self.reload()
        return self.http_delete(self.id, etag=self.etag)
66413
def delete_many(self, uris):
        
        cache_keys = (self._build_cache_key(uri) for uri in uris)
        self._delete_many(cache_keys)
814258
def get_delete(url, id, method, key=None):
        
        return Util(
            url=url + id + "/",
            method=method,
            key=key,
        ).json_result()
1231009
def clean_link(self, url):
        """"""
        return self._clean_re.sub(lambda match: "%%%2x" % ord(match.group(0)), url)
300922
def _remove_duplicates(self, items):
        
        result = []
        for i in items:
            if i not in result:
                result.append(i)
        return result
1299653
def deleted_count(self):
        """"""
        if isinstance(self.raw_result, list):
            return len(self.raw_result)
        else:
            return self.raw_result
224803
def remove_cached_item(self, path):
        
        item_path = '%s/%s' % (
                self.cache_folder,
                path.strip('/')
            )

        self.blob_service.delete_blob(self.container_name, item_path)

        while self.blob_service.exists(self.container_name, item_path):
            time.sleep(0.5)

        return True
406610
def cache_clear(self):
        
        # Delete content of local cache directory
        for f in os.listdir(self.directory):
            f = os.path.join(self.directory, f)
            if os.path.isfile(f):
                os.remove(f)
            elif os.path.isdir(f):
                shutil.rmtree(f)
        # Empty cache index
        self.cache = {}
1175071
def delete(self, url, headers=None, kwargs=None):
        
        return self._request(
            method='delete',
            url=url,
            headers=headers,
            kwargs=kwargs
        )
766135
async def remove_items(self, *items):
    '''
    '''
    items = [i.id for i in (await self.process(items)) if i in self.items]
    if not items:
      return

    await self.connector.delete(
      'Playlists/{Id}/Items'.format(Id=self.id),
      EntryIds=','.join(items),
      remote=False
    )
574890
def _maybe_purge_cache(self):
        

        if self._last_reload_check + MIN_CHECK_INTERVAL > time.time():
            return

        for name, tmpl in list(self.cache.items()):
            if not os.stat(tmpl.path):
                self.cache.pop(name)
                continue

            if os.stat(tmpl.path).st_mtime > tmpl.mtime:
                self.cache.clear()
                break

        self._last_reload_check = time.time()
672303
def _purge(self):
        
        if len(self.cache) <= self.max_size:
            return

        cache = self.cache
        refcount = self.refcount
        queue = self.queue
        max_size = self.max_size

        # purge least recently used entries, using refcount to count entries
        # that appear multiple times in the queue
        while len(cache) > max_size:
            refc = 1
            while refc:
                k = queue.popleft()
                refc = refcount[k] = refcount[k] - 1
            del cache[k]
            del refcount[k]
1128213
def _remove_qs(self, url):
        '''
        
        '''
        scheme, netloc, path, query, fragment = urlsplit(url)

        return urlunsplit((scheme, netloc, path, '', fragment))
773817
def removed(self):
        '''
        
        '''
        def _removed(diffs, prefix):
            keys = []
            for key in diffs.keys():
                if isinstance(diffs[key], dict) and 'old' not in diffs[key]:
                    keys.extend(_removed(diffs[key],
                                       prefix='{0}{1}.'.format(prefix, key)))
                elif diffs[key]['new'] == self.NONE_VALUE:
                    keys.append('{0}{1}'.format(prefix, key))
                elif isinstance(diffs[key]['new'], dict):
                    keys.extend(
                        _removed(diffs[key]['new'],
                                 prefix='{0}{1}.'.format(prefix, key)))
            return keys

        return sorted(_removed(self._diffs, prefix=''))
553819
def purge():
    
    all_hashes = read_all()
    used_hashes = read_used()
    for kind, hashes in used_hashes.items():
        hashes = set(hashes)
        to_remove = set(all_hashes[kind]).difference(hashes)
        delete_from_directory_by_hashes(kind, to_remove)

    reset_used()
    write_out()