Each Cached object has multiple Segments that need cleaning.  Derive each, and add to Cleansing Thread
@param env
@param dao
555492
public static void startCleansing(AuthzEnv env, CachedDAO<?,?,?> ... dao) {
		for(CachedDAO<?,?,?> d : dao) {  
			for(int i=0;i<d.segSize;++i) {
				startCleansing(env, d.table()+i);
			}
		}
	}
214533
private static <T, ID, I extends GenericDAO<T, ID>> Class<? extends I> completeDAO(Class<T> modelClass,
                                                                                       Class<I> daoInterface,
                                                                                       Class<? extends QueryModelDAO<T, ID>> partialDAOClass,
                                                                                       boolean accessControlEnabled,
                                                                                       boolean metricsEnabled) {
        try {
            ClassPool pool = ClassPool.getDefault();

            pool.insertClassPath(new ClassClassPath(daoInterface));

            CtClass fullDAOCtClass = pool.makeClass(String.format("%s$%d", daoInterface.getName(), count.incrementAndGet()));
            CtClass partialDAOCtClass = pool.get(partialDAOClass.getName());
            CtClass daoInterfaceCtClass = pool.get(daoInterface.getName());

            fullDAOCtClass.setSuperclass(partialDAOCtClass);
            fullDAOCtClass.addInterface(daoInterfaceCtClass);

            buildConstructor(fullDAOCtClass, accessControlEnabled);
            buildNeededMethods(fullDAOCtClass, partialDAOCtClass, daoInterfaceCtClass, modelClass, accessControlEnabled, metricsEnabled);

            return ClassLoadingUtil.toClass(fullDAOCtClass);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
702627
public void save(ProcessingEnvironment env) throws IOException
    {
        Filer filer = env.getFiler();
        //JavaFileObject sourceFile = filer.createClassFile(getQualifiedName(), superClass);
        FileObject sourceFile = filer.createResource(
                StandardLocation.CLASS_OUTPUT, 
                El.getPackageOf(this).getQualifiedName(), 
                getSimpleName()+".class"
                );
        BufferedOutputStream bos = new BufferedOutputStream(sourceFile.openOutputStream());
        DataOutputStream dos = new DataOutputStream(bos);
        write(dos);
        dos.close();
        System.err.println("wrote "+sourceFile.getName());
    }
1061733
def remove_methods(self, env):
        
        for method in list(self.methods.values()):
            env.RemoveMethod(method)
32301
private void clean(Connection conn) {
        this.selectColumns = null;
        this.isSQLLimit = false;
        this.orderBySQL = new StringBuilder();
        this.conditionSQL = new StringBuilder();
        this.paramValues.clear();
        this.excludedColumns.clear();
        this.updateColumns.clear();

        ifThen(localConnection.get() == null && conn != null,
                () -> conn.close());
    }
225867
public void removeAll(Object object) {
		for (Entry<Integer, List<EventQueueEntry>> e : queue.entrySet()) {
			List<EventQueueEntry> entries = e.getValue();
			
			List<EventQueueEntry> toRemove = new LinkedList<>();
			synchronized (entries) {
				for (EventQueueEntry entry : entries) {
					if (entry.getObject() == object) {
						toRemove.add(entry);
					}
				}
				
				entries.removeAll(toRemove);
				
				// TODO: can we safely remove `entries` if it's empty here?
			}
		}
		
		log.debug(
				"Removed {} from notification queue for {}",
				object, eventType);
	}
944906
public void clear(Object key) {
		Object removed;
		if (isCachingEnabled()) {
			synchronized (mirror) {
				synchronized (data) {
					removed = data.remove(key);
					mirror.remove(key);
				}
			}
			System.out.println(new LogEntry("object with key " + key + (removed == null ? " NOT" : "") + " removed from cache"));
		}
	}
586499
private void removeCacheByUpdateConditon(Executor executor, MappedStatement mt, String mapperNameSpace,
			Object[] args) {
		try {					
			Object parameterObject = args[1];
			if(parameterObject != null && parameterObject.getClass().getName().equals(TK_MAPPER_EXAMPLE_CLASS_NAME)){
				//清除group下所有缓存
				removeCacheByGroup(mt.getId(), mapperNameSpace,true);
				logger.warn("[tk.mybatis.mapper.entity.Example] Not recommended for use with [@Cache],may be caching cleanup failure",TK_MAPPER_EXAMPLE_CLASS_NAME,mapperNameSpace);
				return;
			}
			EntityInfo entityInfo = MybatisMapperParser.getEntityInfoByMapper(mapperNameSpace);
			MappedStatement statement = getQueryIdsMappedStatementForUpdateCache(mt,entityInfo);
			if(statement == null)return ;
			
			String querySql = statement.getSqlSource().getBoundSql(parameterObject).getSql();
			
			List<?> idsResult = null;
			if(PARSE_SQL_ERROR_DEFAULT.equals(querySql)){
				BoundSql boundSql = mt.getBoundSql(parameterObject);
				querySql = "select "+entityInfo.getIdColumn()+" from "+entityInfo.getTableName()+" WHERE " + boundSql.getSql().split(WHERE_REGEX)[1];
				BoundSql queryBoundSql = new BoundSql(statement.getConfiguration(), querySql, boundSql.getParameterMappings(), parameterObject);
	             
				idsResult = executor.query(statement, parameterObject, RowBounds.DEFAULT, new DefaultResultHandler(),null,queryBoundSql);
			}else{
				idsResult = executor.query(statement, parameterObject, RowBounds.DEFAULT, null);
			}
			
			if(idsResult != null && !idsResult.isEmpty()){
				for (Object id : idsResult) {							
					String cacheKey = entityInfo.getEntityClass().getSimpleName() + ID_CACHEKEY_JOIN + id.toString();
					getCacheProvider().remove(cacheKey);
				}
				if(logger.isDebugEnabled())logger.debug("_autocache_ update Method[{}] executed,remove ralate cache {}.id:[{}]",mt.getId(),entityInfo.getEntityClass().getSimpleName(),idsResult);
			}
		} catch (Exception e) {
			//清除group下所有缓存
			removeCacheByGroup(mt.getId(), mapperNameSpace,true);
			logger.error("_autocache_ removecache_by_update [{}] error,force clean all group cache",mt.getId());
		}
	}
839356
public void remove(Object e)
    {
        // Invoke Pre Remove Events

        // TODO Check for validity also as per JPA
        if (e == null)
        {
            throw new IllegalArgumentException("Entity to be removed must not be null.");
        }

        EntityMetadata metadata = getMetadata(e.getClass());

        // Create an object graph of the entity object
        ObjectGraph graph = new GraphGenerator().generateGraph(e, this, new ManagedState());

        Node node = graph.getHeadNode();

        try
        {
            lock.writeLock().lock();

            // TODO : push into action queue, get original end-point from
            // persistenceContext first!

            // Action/ExecutionQueue/ActivityQueue :-> id, name, EndPoint,
            // changed
            // state

            // Change state of node, after successful flush processing.
            node.setPersistenceDelegator(this);
            node.remove();

            // build flush stack.

            flushManager.buildFlushStack(node, EventType.DELETE);

            // Flush node.
            flush();
        }
        finally
        {
            lock.writeLock().unlock();
        }
        // clear out graph
        graph.clear();
        graph = null;

        if (log.isDebugEnabled())
        {
            log.debug("Data removed successfully for entity : " + e.getClass());
        }
    }
1012922
@SuppressWarnings("javadoc")
	public void removeFactory(ValidatorFactory factory) {
		// this is to avoid adding items to the cache that were removed while
		// iterating
		synchronized (map) {
			providers.remove(factory);
			map.clear();
		}
	}
669016
public static void unregisterDao(ConnectionSource connectionSource,
			Class<?> clazz) {

		Dao<?, ?> dao = DaoManager.lookupDao(connectionSource, clazz);
		if (dao != null) {
			DaoManager.unregisterDao(connectionSource, dao);
		}

	}
1139503
@Override
	public void cache(final Object key, final Object object) {
		this.logger.debug("@cache ");

		if (object == null) {
			if (!isAllowNullable()) {
				return;
			}
			this.logger.debug("logging key :", key, " with null");
			getCachableMap(JKAbstractCacheManager.NULLABLE_MAP_CLASS).put(key, null);
		} else {
			cache(key, object, object.getClass());
		}
	}
395845
public static void resolve(Map<String, String> env) {
		for (Map.Entry<String,String> entry: env.entrySet()) {
			entry.setValue(Util.replaceMacro(entry.getValue(), env));
		}
	}
486997
public static synchronized void unregisterDao(ConnectionSource connectionSource, Dao<?, ?> dao) {
		if (connectionSource == null) {
			throw new IllegalArgumentException("connectionSource argument cannot be null");
		}
		removeDaoToClassMap(new ClassConnectionSource(connectionSource, dao.getDataClass()));
	}
405765
private void removeAccoundDependencies(Sid sid) {
        logger.debug("removing accoutn dependencies");
        DaoManager daoManager = (DaoManager) context.getAttribute(DaoManager.class.getName());
        // remove dependency entities first and dependent entities last. Also, do safer operation first (as a secondary rule)
        daoManager.getAnnouncementsDao().removeAnnouncements(sid);
        daoManager.getNotificationsDao().removeNotifications(sid);
        daoManager.getShortCodesDao().removeShortCodes(sid);
        daoManager.getOutgoingCallerIdsDao().removeOutgoingCallerIds(sid);
        daoManager.getTranscriptionsDao().removeTranscriptions(sid);
        daoManager.getRecordingsDao().removeRecordings(sid);
        daoManager.getApplicationsDao().removeApplications(sid);
        removeIncomingPhoneNumbers(sid,daoManager.getIncomingPhoneNumbersDao());
        daoManager.getClientsDao().removeClients(sid);
        profileAssociationsDao.deleteProfileAssociationByTargetSid(sid.toString());
    }
1053247
final void cleanLocks() throws RepositoryException {
        // clean the session-scoped locks: unlock all the nodes and remove the lock tokens from the system area
        Set<String> cleanedTokens = lockManager.cleanLocks(session);
        if (lockTokens.isEmpty()) {
            return;
        }
        // clean all open-scoped locks created via this session
        for (String lockToken : lockTokens) {
            if (!cleanedTokens.contains(lockToken)) {
                ModeShapeLock lock = lockManager.findLockByToken(lockToken);
                if (lock == null) {
                    // there is no existing lock for this token (it must've been removed from somewhere else)
                    continue;
                }
                // this is an open-scoped lock created via this session for which we'll have to update the 'held' flag
                if (!lockManager.setHeldBySession(session, lockToken, false)) {
                    // Generally not expected, because if the lock exists we can always change the lock-held value to false
                    // even when it is already false ...
                    throw new LockException(JcrI18n.invalidLockToken.text(lockToken));
                }
            }
        }
        // always clean our internal map of tokens
        lockTokens.clear();
    }
344173
public void detach(Object entity)
    {
        Node node = getPersistenceCache().getMainCache().getNodeFromCache(entity, getMetadata(entity.getClass()), this);
        if (node != null)
        {
            node.detach();
        }
    }