Cache script if it is not already cached.
439373
def cache_script(script, text, opts={}):
    """"""
    global script_cache
    if script not in script_cache:
        update_script_cache(script, text, opts)
        pass
    return script
605409
def has(self):
        """"""
        self._done = os.path.exists(self._cache_file)
        return self._done or self._out is not None
529753
def cache(self, con):
        """"""
        try:
            if self._reset == 2:
                con.reset()  # reset the connection completely
            else:
                if self._reset or con._transaction:
                    try:
                        con.rollback()  # rollback a possible transaction
                    except Exception:
                        pass
            self._cache.put(con, 0)  # and then put it back into the cache
        except Full:
            con.close()
        if self._connections:
            self._connections.release()
495981
def set(self, key, *args):
        """"""
        return self.cache.set(self._hashed(key), *args)
323628
def script(self):
        """"""
        # The script object is cached, since constructing it may involve
        # a number of string-manipulation operations.
        if getattr(self, '_script', None) is None:
            self._script = self._script__getter()
        return self._script
887847
function (fullpath, publname) {

    var curr_time = new Date();

    // store script if modified for first time
    if (fullpath !== undefined && publname !== undefined) {

        if (l_modified_scripts.hasOwnProperty(fullpath) === false) {
                            
            LOG.warn('script modified: ' + fullpath, l_name);
            l_modified_scripts[fullpath] = {
                time: new Date(curr_time.getTime() + l_reloadTime * 1000),
                name: publname
            };
        }
        // if already stored, ignore this request
        else
            return;
    }
    else {

        // check queue for scripts that can be safely reloaded
        for (var path in l_modified_scripts) {
        
            // check if wait time has expired
            if (curr_time - l_modified_scripts[path].time > 0) {

                // get public name
                var name = l_modified_scripts[path].name;
                var notify_msg = 'reloading [' + name + '] from: ' + path;
				LOG.warn(notify_msg, l_name);
				
				// send e-mail notify to project admin (only if specified)
				if (SR.Settings.NOTIFY_SCRIPT_RELOAD === true)
					UTIL.notifyAdmin('script reloading', notify_msg);

				// save current script in cache as backup
				var backup_script = require.cache[path];

                // NOTE: if 'path' is incorrect, may not delete successfully, and new script won't load
                delete require.cache[path];
				
				// NOTE: this will show false
				//LOG.warn('after delete, has path: ' + require.cache.hasOwnProperty(path), l_name);
				
                // NOTE: something can go wrong if the script is corrupt
                try {
                    // re-require
					if (l_args.hasOwnProperty(path)) {
						LOG.warn('args exist..', l_name);
						require(path)(l_args[path]);
						l_loaded[name] = require.cache[path];
					}
					else {
                    	l_loaded[name] = require(path);
						SR.Handler.add(l_loaded[name]);						
					}						
				}
                catch (e) {
					LOG.error('reload error: ', l_name);
					LOG.error(UTIL.dumpError(e), l_name);
					
					LOG.warn('restoring old script...', l_name);
					require.cache[path] = backup_script;
					l_loaded[name] = require.cache[path];
					
					// this will show 'true'
					//LOG.warn('after restore, has path: ' + require.cache.hasOwnProperty(path), l_name);         
                }

                // remove file record
                delete l_modified_scripts[path];
            }
        }
    }

    // reload myself to check later if there are scripts to be loaded
    if (Object.keys(l_modified_scripts).length > 0) {
        var timeout = l_reloadTime * 1.5 * 1000;
        LOG.sys('automatic reloading after: ' + timeout + ' ms', l_name);
        setTimeout(l_loadScript, timeout);
    }        
}
325476
def _write_cache(self, lines, append=False):
        """"""
        mode = 'at' if append else 'wt'
        with open(self.filepath, mode, encoding='utf8') as fh:
            fh.writelines(line + '\n' for line in lines)
173179
def cache_page(page_cache, page_hash, cache_size):
    """"""
    page_cache.append(page_hash)
    if len(page_cache) > cache_size:
        page_cache.pop(0)
1228429
def check_cache(self, template):
        '''
        
        '''
        if template not in self.cached:
            self.cache_file(template)
            self.cached.append(template)
533110
def reload_stale
      reload_check = should_reload?
      self.last_reload = Time.now

      return if ! reload_check
      reset!

      self.scripts.each do |f|
        debug_log "reload #{f}"
        load f
      end
    end
468386
def cached(namespace=None, service="memory", debug=False):
    
    _service = getattr(debris.services, service)
    def wrapper(_f):
        @functools.wraps(_f)
        def _stash(self, *a, **k):
            if debug is False:
                # this request is cacheable
                try:
                    self.finish(_service.get(namespace))
                except LookupError:
                    _replace_finish(self, namespace, _service)
                    # get the result of this request
                    _f(self, *a, **k)
                return
            # request is not cacheable
            _f(self, *a, **k)
        return _stash
    return wrapper
410779
def cache_key_exist(self, key):
        """"""
        key_exist = True if cache.get(key) else False
        status = 200 if key_exist else 404
        return json_success(json.dumps({'key_exist': key_exist}),
                            status=status)
917277
function existsInCache(x, cache) {
  var found = _.find(cache, function(y) {
    return appsAreEqual(x, y);
  });
  return !!found;
}
237247
def cached(func):
    """"""
    ret = None

    def call_or_cache(*args, **kwargs):
        nonlocal ret
        if ret is None:
            ret = func(*args, **kwargs)
        return ret

    return call_or_cache
630452
function () {
		var updateCache = this.cache;
		for (var i = 0, n = updateCache.length; i < n; i++)
			updateCache[i].update();
	}
1041506
def cache(ctx, clear_subliminal):
    """"""
    if clear_subliminal:
        for file in glob.glob(os.path.join(ctx.parent.params['cache_dir'], cache_file) + '*'):
            os.remove(file)
        click.echo('Subliminal\'s cache cleared.')
    else:
        click.echo('Nothing done.')
99053
def script_exists(self, digest, *digests):
        """"""
        return self.execute(b'SCRIPT', b'EXISTS', digest, *digests)