We cache the controller object which will reference the object template and expire it as long as there are no pending calls.  Note that with a memory store session manager the act of referencing the session will expire it if needed
777214
function teamOutAction() {
        sessionStore.get(sessionId, function aa(_error, expressSession) {
            if (!expressSession) {
                log(1, sessionId, 'Session has expired', nonObjTemplatelogLevel);
            }

            if (!expressSession ||
                cachedController.controller.__template__.objectTemplate.getPendingCallCount() === 0) {
                controllers[sessionId + path] = null;
                log(1, sessionId, 'Expiring controller cache for ' + path, nonObjTemplatelogLevel);
            }
            else {
                cachedController.timeout = setTimeout(timeoutAction, objectCacheExpiration);
                log(2, sessionId, 'Extending controller cache timeout because of pending calls for ' + path,
 -                    nonObjTemplatelogLevel);
            }
        });
    }
131325
function() {
      var self = this;
      if (self._refreshingCache) {
        return;
      }
      self._refreshingCache = true;
      Parse._objectEach(this.attributes, function(value, key) {
        if (value instanceof Parse.Object) {
          value._refreshCache();
        } else if (_.isObject(value)) {
          if (self._resetCacheForKey(key)) {
            self.set(key, new Parse.Op.Set(value), { silent: true });
          }
        }
      });
      delete self._refreshingCache;
    }
196229
public void clearAllQueryCaches()
    {
        MithraRuntimeCacheController[] controllers;
        synchronized (this)
        {
            controllers = new MithraRuntimeCacheController[this.runtimeCacheControllerSet.size()];
            Iterator<MithraRuntimeCacheController> setIterator = this.runtimeCacheControllerSet.iterator();
            for (int i=0; i<this.runtimeCacheControllerSet.size(); i++)
            {
                controllers[i] = setIterator.next();
            }
        }
        for (MithraRuntimeCacheController controller : controllers)
        {
            controller.clearQueryCache();
        }
    }
1286283
static function cleanup()
    {
        $http = eZHTTPTool::instance();

        $http->removeSessionVariable( 'CanInstantiateClassList' );
        $http->removeSessionVariable( 'ClassesCachedForUser' );

        // Note: This must be done more generic with an internal
        //       callback system.
        eZPreferences::sessionCleanup();
    }
912958
function verifyExpiration() {
    if (opt.removeExpired === false) return;
    let now = Date.now();
    Object.keys(SESSION_STORE).forEach((id) => {
      let item = SESSION_STORE[id];
      if (!item) return;
      if (now < item.e) return;
      delete SESSION_STORE[id];
    });
  }
260379
public void cache(String key, Object obj) {
        H.Session sess = session();
        if (null != sess) {
            sess.cache(key, obj);
        } else {
            app().cache().put(key, obj);
        }
    }
1046535
public void cache(Identity oid, Object obj)
    {
        if (oid != null && obj != null)
        {
            ObjectCache cache = getCache(oid, obj, METHOD_CACHE);
            if (cache != null)
            {
                cache.cache(oid, obj);
            }
        }
    }
616681
public void clearUnused() {
	Log log = getLog();
	try {
	    // create cleaner engine for session/client scope
	    if (session == null) session = new StorageScopeEngine(factory, log, new StorageScopeCleaner[] { new FileStorageScopeCleaner(Scope.SCOPE_SESSION, null)// new
		    // SessionEndListener())
		    , new DatasourceStorageScopeCleaner(Scope.SCOPE_SESSION, null)// new
		    // SessionEndListener())
		    // ,new CacheStorageScopeCleaner(Scope.SCOPE_SESSION, new SessionEndListener())
	    });
	    if (client == null) client = new StorageScopeEngine(factory, log,
		    new StorageScopeCleaner[] { new FileStorageScopeCleaner(Scope.SCOPE_CLIENT, null), new DatasourceStorageScopeCleaner(Scope.SCOPE_CLIENT, null)
		    // ,new CacheStorageScopeCleaner(Scope.SCOPE_CLIENT, null) //Cache storage need no control, if
		    // there is no listener
		    });
	    // store session/client scope and remove from memory
	    storeUnusedStorageScope(factory, Scope.SCOPE_CLIENT);
	    storeUnusedStorageScope(factory, Scope.SCOPE_SESSION);

	    // remove unused memory based client/session scope (invoke onSessonEnd)
	    clearUnusedMemoryScope(factory, Scope.SCOPE_CLIENT);
	    clearUnusedMemoryScope(factory, Scope.SCOPE_SESSION);

	    // session must be executed first, because session creates a reference from client scope
	    session.clean();
	    client.clean();

	    // clean all unused application scopes
	    clearUnusedApplications(factory);
	}
	catch (Exception t) {
	    error(t);
	}
    }
121638
protected void initCacheObject() {

        CmsFlexController controller = (CmsFlexController)getJsp().getRequest().getAttribute(
            CmsFlexController.ATTRIBUTE_NAME);
        CmsFlexCache cache = controller.getCmsCache();

        setVariations("" + cache.size());
        setKeys("" + cache.keySize());
        CmsLruCache entryLruCache = cache.getEntryLruCache();

        if (entryLruCache != null) {
            Locale locale = getLocale();
            setMaxSize(CmsFileUtil.formatFilesize(entryLruCache.getMaxCacheCosts(), locale));
            setAvgSize(CmsFileUtil.formatFilesize(entryLruCache.getAvgCacheCosts(), locale));
            setCurSize(CmsFileUtil.formatFilesize(entryLruCache.getObjectCosts(), locale));
        }
    }
650296
public static function expireSessionCookie()
    {
        if (self::$_unitTestEnabled) {
            return;
        }

        if (self::$_sessionCookieDeleted) {
            return;
        }

        self::$_sessionCookieDeleted = true;

        if (isset($_COOKIE[session_name()])) {
            $cookie_params = session_get_cookie_params();

            setcookie(
                session_name(),
                false,
                315554400, // strtotime('1980-01-01'),
                $cookie_params['path'],
                $cookie_params['domain'],
                $cookie_params['secure']
                );
        }
    }
2445
function (sid, callback) {
    this.sessions.findOne({
      _id: sid,
      $or: [
        { expires: { $exists: false } },
        { expires: { $gt: new Date() } }
      ]
    }, function (err, session_data) {
      if (err) {
        if (callback) callback(err);
        return;
      }
      session_data = cleanSessionData(session_data);
      if (callback) callback(null, session_data);
    });
  }
110543
function(){
    var i;
    var args = slice(arguments);
    var length = args.length;

    if (length > 0){
      for(i=0; i<length; i++){
        delete this.templateCaches[args[i]];
      }
    } else {
      this.templateCaches = {};
    }
  }
62899
def expire_cache(fragment_name, *args):
    
    cache_key = make_template_fragment_key(fragment_name, args)
    cache.delete(cache_key)
344975
public static function expireCache()
    {
        $handler = eZExpiryHandler::instance();
        $handler->setTimestamp( self::CACHE_SIGNATURE, time() );
        $handler->store();

        self::$wildcardsIndex = null;
    }
752290
def cache_data(self, request, data, key='params'):
        
        request.session['%s:%s' % (constants.SESSION_KEY, key)] = data
384140
protected final void cacheClear() {

        int i = sysTables.length;

        while (i-- > 0) {
            Table t = sysTables[i];

            if (t != null) {
                t.clearAllData(session);
            }

            sysTableSessions[i] = null;
        }

        isDirty = false;
    }
1226674
function(localPropOnly) {
    if (this.ctlWrapper) {
      this.ctlWrapper.$dispose();
      this.ctlWrapper=null;
      this.controller=null;
    }
    this.ctlAttributes=null;
    this.cleanObjectProperties(localPropOnly);
    this.ctlConstuctor=null;
    var tpa=this.tplAttributes;
    if (tpa) {
      for (var k in tpa) {
        if (tpa.hasOwnProperty(k)) {
          tpa[k].$dispose();
        }
      }
    }
    var ag=this._attGenerators;
    if (ag) {
      for (var k in ag) {
        if (ag.hasOwnProperty(k)) {
          ag[k].$dispose();
        }
      }
    }
    var en=this.attEltNodes;
    if (en) {
      for (var i=0,sz=en.length; sz>i; i++) {
        en[i].$dispose();
      }
      this.attEltNodes=null;
    }
  }