Get a state file from the master and store it in the local minion
        cache; return the location of the file
334176
def get_state(self, sls, saltenv, cachedir=None):
        '''
        
        '''
        if '.' in sls:
            sls = sls.replace('.', '/')
        sls_url = salt.utils.url.create(sls + '.sls')
        init_url = salt.utils.url.create(sls + '/init.sls')
        for path in [sls_url, init_url]:
            dest = self.cache_file(path, saltenv, cachedir=cachedir)
            if dest:
                return {'source': path, 'dest': dest}
        return {}
249238
def local(self, fun, tgt, **kwargs):
        '''
        
        '''
        self.client_cache['local'].cmd_async(tgt, fun, **kwargs)
915679
def cache_file(self, template):
        '''
        
        '''
        saltpath = salt.utils.url.create(template)
        self.file_client().get_file(saltpath, '', True, self.saltenv)
272609
protected Reader retrieveFromCache(String path, GeneratorContext context, CacheMode cacheMode) {

		Reader rd = null;
		String filePath = getTempFilePath(context, cacheMode);
		
		FileInputStream fis = null;
		File file = new File(filePath);
		if (file.exists()) {
			try {
				fis = new FileInputStream(file);
			} catch (FileNotFoundException e) {
				throw new BundlingProcessException("An error occured while creating temporary resource for " + filePath,
						e);
			}
			FileChannel inchannel = fis.getChannel();
			rd = Channels.newReader(inchannel, context.getConfig().getResourceCharset().newDecoder(), -1);
			context.setRetrievedFromCache(true);
			if (LOGGER.isDebugEnabled()) {
				LOGGER.debug(getName() + " resource '" + path + "' retrieved from cache");
			}
		}
		return rd;
	}
1306550
def cache_file(self, path, saltenv='base', cachedir=None, source_hash=None):
        '''
        
        '''
        return self.get_url(
            path, '', True, saltenv, cachedir=cachedir, source_hash=source_hash)
1299068
def get_file(path,
             dest,
             saltenv='base',
             makedirs=False,
             template=None,
             gzip=None):
    '''
    
    '''
    if gzip is not None:
        log.warning('The gzip argument to cp.get_file in salt-ssh is '
                    'unsupported')

    if template is not None:
        (path, dest) = _render_filenames(path, dest, saltenv, template)

    src = __context__['fileclient'].cache_file(
        path,
        saltenv,
        cachedir=os.path.join('salt-ssh', __salt__.kwargs['id_']))
    single = salt.client.ssh.Single(
            __opts__,
            '',
            **__salt__.kwargs)
    ret = single.shell.send(src, dest, makedirs)
    return not ret[2]
630921
public static Path getLocalCache(URI cache, Configuration conf, Path subdir,
      FileStatus fileStatus, boolean isArchive, long confFileStamp, Path
      currentWorkDir, boolean honorSymLinkConf, MRAsyncDiskService
      asyncDiskService, LocalDirAllocator lDirAllocator)
  throws IOException {
    return getLocalCache(cache, conf, subdir, fileStatus, isArchive,
        confFileStamp, fileStatus.getLen(), currentWorkDir, honorSymLinkConf,
        asyncDiskService, lDirAllocator);
  }
497900
def check_minion_cache(self, preserve_minions=None):
        '''
        
        '''
        if preserve_minions is None:
            preserve_minions = []
        keys = self.list_keys()
        minions = []
        for key, val in six.iteritems(keys):
            minions.extend(val)
        if not self.opts.get('preserve_minion_cache', False):
            m_cache = os.path.join(self.opts['cachedir'], self.ACC)
            if os.path.isdir(m_cache):
                for minion in os.listdir(m_cache):
                    if minion not in minions and minion not in preserve_minions:
                        try:
                            shutil.rmtree(os.path.join(m_cache, minion))
                        except (OSError, IOError) as ex:
                            log.warning('Key: Delete cache for %s got OSError/IOError: %s \n',
                                        minion,
                                        ex)
                            continue
            cache = salt.cache.factory(self.opts)
            clist = cache.list(self.ACC)
            if clist:
                for minion in clist:
                    if minion not in minions and minion not in preserve_minions:
                        cache.flush('{0}/{1}'.format(self.ACC, minion))
540069
def load_cache():
    
    if not os.path.exists(settings.DUP_FILTER_FILE):
        return set()

    with open(settings.DUP_FILTER_FILE) as f:
        return set(
            json.loads(f.read())
        )
1083518
def _cache_id(minion_id, cache_file):
    '''
    
    '''
    path = os.path.dirname(cache_file)
    try:
        if not os.path.isdir(path):
            os.makedirs(path)
    except OSError as exc:
        # Handle race condition where dir is created after os.path.isdir check
        if os.path.isdir(path):
            pass
        else:
            log.error('Failed to create dirs to minion_id file: %s', exc)

    try:
        with salt.utils.files.fopen(cache_file, 'w') as idf:
            idf.write(minion_id)
    except (IOError, OSError) as exc:
        log.error('Could not cache minion ID: %s', exc)
1101579
def get_minion_data(minion, opts):
    '''
    
    '''
    grains = None
    pillar = None
    if opts.get('minion_data_cache', False):
        cache = salt.cache.factory(opts)
        if minion is None:
            for id_ in cache.list('minions'):
                data = cache.fetch('minions/{0}'.format(id_), 'data')
                if data is None:
                    continue
        else:
            data = cache.fetch('minions/{0}'.format(minion), 'data')
        if data is not None:
            grains = data.get('grains', None)
            pillar = data.get('pillar', None)
    return minion if minion else None, grains, pillar
403113
def cache_get(cache_dir, cache_key, default=None):
    
    filename = os.path.join(cache_dir, cache_key)

    if os.path.isfile(filename):
        with open(filename, 'r') as f:
            return f.read()

    return default
894536
function getCacheStatus(file: Object): string {
  return [
    file.content.status,
    file.headers.status,
    file.remote.status
  ].reduce((prev, cur) => {
    const unchanged = cur === prev && (prev === LocalStatus.New || prev === LocalStatus.Unchanged);
    return unchanged ? prev : LocalStatus.Changed;
  });
}
1253055
def get_state_search_path_list(saltenv='base'):
        '''
        
        '''
        # state cache should be updated before running this method
        search_list = []
        cachedir = __opts__.get('cachedir', None)
        log.info("Searching for files in saltenv: %s", saltenv)
        path = cachedir + os.sep + "files" + os.sep + saltenv
        search_list.append(path)
        return search_list
1181035
def minion_runner(self, clear_load):
        '''
        
        '''
        load = self.__verify_load(clear_load, ('fun', 'arg', 'id', 'tok'))
        if load is False:
            return {}
        else:
            return self.masterapi.minion_runner(clear_load)
1000397
def gather_cache(self):
        '''
        
        '''
        cache = {'grains': {}, 'pillar': {}}
        if self.grains or self.pillar:
            if self.opts.get('minion_data_cache'):
                minions = self.cache.list('minions')
                if not minions:
                    return cache
                for minion in minions:
                    total = self.cache.fetch('minions/{0}'.format(minion), 'data')

                    if 'pillar' in total:
                        if self.pillar_keys:
                            for key in self.pillar_keys:
                                if key in total['pillar']:
                                    cache['pillar'][minion][key] = total['pillar'][key]
                        else:
                            cache['pillar'][minion] = total['pillar']
                    else:
                        cache['pillar'][minion] = {}

                    if 'grains' in total:
                        if self.grain_keys:
                            for key in self.grain_keys:
                                if key in total['grains']:
                                    cache['grains'][minion][key] = total['grains'][key]
                        else:
                            cache['grains'][minion] = total['grains']
                    else:
                        cache['grains'][minion] = {}
        return cache
917880
def get_cached(self):
        '''
        
        '''
        msg = self.serial.dumps('minions')
        self.creq_out.send(msg)
        min_list = self.serial.loads(self.creq_out.recv())
        return min_list