// ClearCache allows to clear either all caches or specific cached associated with one ore more indices.
// see http://www.elasticsearch.org/guide/reference/api/admin-indices-clearcache/
489616
func (c *Conn) ClearCache(clearId bool, clearBloom bool, args map[string]interface{}, indices ...string) (ExtendedStatus, error) {
	var retval ExtendedStatus
	var clearCacheUrl string
	if len(indices) > 0 {
		clearCacheUrl = fmt.Sprintf("/%s/_cache/clear", strings.Join(indices, ","))

	} else {
		clearCacheUrl = fmt.Sprintf("/_cache/clear")
	}

	body, err := c.DoCommand("POST", clearCacheUrl, args, nil)
	if err != nil {
		return retval, err
	}
	if err == nil {
		// marshall into json
		jsonErr := json.Unmarshal(body, &retval)
		if jsonErr != nil {
			return retval, jsonErr
		}
	}
	return retval, err
}
1089172
func (l *lru) UpdateCache(mts []core.Metric, _ string) {
	l.updateCache(mts)
}
536489
func (engine *Engine) ClearCacheBean(bean interface{}, id string) error {
	tableName := engine.TableName(bean)
	cacher := engine.getCacher(tableName)
	if cacher != nil {
		cacher.ClearIds(tableName)
		cacher.DelBean(tableName, id)
	}
	return nil
}
603297
func (api *WebAccelAPI) DeleteCache(urls ...string) (*WebAccelDeleteCacheResponse, error) {

	type request struct {
		// URL
		URL []string
	}

	uri := fmt.Sprintf("%s/deletecache", api.getResourceURL())

	data, err := api.client.newRequest("POST", uri, &request{URL: urls})
	if err != nil {
		return nil, err
	}

	var res WebAccelDeleteCacheResponse
	if err := json.Unmarshal(data, &res); err != nil {
		return nil, err
	}
	return &res, nil
}
119233
func (c *Cache) ClearTill(till time.Time) {
	c.mu.Lock()
	defer c.mu.Unlock()

	if c.destDir != "" {
		// all in same dir. also remove files with different suffixes (e.g. foo.map.font.lst)
		files, err := filepath.Glob(filepath.Join(c.destDir, stylePrefix+"*"))
		if err != nil {
			log.Println("cleanup error: ", err)
			return
		}
		for _, f := range files {
			if fi, err := os.Stat(f); err == nil && fi.ModTime().Before(till) {
				if err := os.Remove(f); err != nil {
					log.Println("cleanup error: ", err)
				}
			}
		}
	} else {
		// with empty destDir, each style is in its own temp dir.
		for _, style := range c.styles {
			if fi, err := os.Stat(style.file); err == nil && fi.ModTime().Before(till) {
				if err := os.RemoveAll(filepath.Dir(style.file)); err != nil {
					log.Println(err)
				}
			}
		}
	}

	for hash, _ := range c.styles {
		delete(c.styles, hash)
	}
}
767204
func (c *Cache) ClearSnapshot(success bool) {
	c.mu.RLock()
	snapStore := c.snapshot.store
	c.mu.RUnlock()

	// reset the snapshot store outside of the write lock
	if success {
		snapStore.reset()
	}

	c.mu.Lock()
	defer c.mu.Unlock()

	c.snapshotting = false

	if success {
		snapshotSize := c.tracker.SnapshotSize()
		c.tracker.SetSnapshotsActive(0)
		c.tracker.SubMemBytes(snapshotSize) // decrement the number of bytes in cache

		// Reset the snapshot to a fresh Cache.
		c.snapshot = &Cache{
			store:   c.snapshot.store,
			tracker: newCacheTracker(c.tracker.metrics, c.tracker.labels),
		}

		c.tracker.SetSnapshotSize(0)
		c.tracker.SetDiskBytes(0)
		c.tracker.SetSnapshotsActive(0)
	}
}
917710
func (c *FindCache) PurgeAll() {
	c.RLock()
	orgs := make([]uint32, len(c.cache))
	i := 0
	for k := range c.cache {
		orgs[i] = k
		i++
	}
	c.RUnlock()
	for _, org := range orgs {
		c.Purge(org)
	}
}
87859
func (engine *Engine) ClearCache(beans ...interface{}) error {
	for _, bean := range beans {
		v := rValue(bean)
		t := v.Type()
		if t.Kind() != reflect.Struct {
			return errors.New("error params")
		}
		tableName := engine.tbName(v)
		table := engine.autoMapType(v)
		cacher := table.Cacher
		if cacher == nil {
			cacher = engine.Cacher
		}
		if cacher != nil {
			cacher.ClearIds(tableName)
			cacher.ClearBeans(tableName)
		}
	}
	return nil
}
1020599
func (cache *DiskBlockCacheLocal) ClearHomeTLFs(ctx context.Context) error {
	cache.lock.Lock()
	defer cache.lock.Unlock()
	for tlfID, priority := range cache.homeDirs {
		cache.priorityBlockCounts[priority] -= cache.tlfCounts[tlfID]
		cache.priorityTlfMap[priority][tlfID] -= cache.tlfCounts[tlfID]
		cache.priorityBlockCounts[priorityNotHome] += cache.tlfCounts[tlfID]
		cache.priorityTlfMap[priorityNotHome][tlfID] += cache.tlfCounts[tlfID]
	}
	cache.homeDirs = make(map[tlf.ID]evictionPriority)
	return nil
}
900886
func (cache *snapshotCache) ClearSnapshot(node string) {
	cache.mu.Lock()
	defer cache.mu.Unlock()

	delete(cache.snapshots, node)
	delete(cache.status, node)
}
662246
func (ac *AddressCache) Clear(addrs []string) (numCleared int) {
	if addrs == nil {
		return ac.ClearAll()
	}
	if len(addrs) == 0 {
		return
	}
	ac.mtx.Lock()
	defer ac.mtx.Unlock()
	for i := range addrs {
		delete(ac.a, addrs[i])
		numCleared++
	}
	return
}
1182785
func (c *Cluster) Clear() {
	c.mu.Lock()

	c.members = make(map[uint64]*Member)
	c.removed = make(map[uint64]bool)
	c.mu.Unlock()
}
838548
func (v *Index) Clear() error {
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	err := C.git_index_clear(v.ptr)
	runtime.KeepAlive(v)
	if err < 0 {
		return MakeGitError(err)
	}
	return nil
}
589291
func (s *Project) SetCache(v *ProjectCache) *Project {
	s.Cache = v
	return s
}
585738
func (l *lru) CheckCache(mts []core.Metric, _ string) ([]core.Metric, []core.Metric) {
	return l.checkCache(mts)
}
101654
func (cache *Cache) Clear() {
	for i := range cache.segments {
		cache.locks[i].Lock()
		cache.segments[i].clear()
		cache.locks[i].Unlock()
	}
}
402695
func (l *Loader) Clear(ctx context.Context, key Key) Interface {
	l.cacheLock.Lock()
	l.cache.Delete(ctx, key)
	l.cacheLock.Unlock()
	return l
}