您的当前位置:首页正文

定时任务例子

2024-12-01 来源:个人技术集锦
@EnableScheduling
	@Configuration(proxyBeanMethods = false)
	class SessionCleanupConfiguration implements SchedulingConfigurer {

		private final RedisIndexedSessionRepository sessionRepository;

		SessionCleanupConfiguration(RedisIndexedSessionRepository sessionRepository) {
			this.sessionRepository = sessionRepository;
		}

		@Override
		public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
			taskRegistrar.addCronTask(this.sessionRepository::cleanupExpiredSessions,
					RedisHttpSessionConfiguration.this.cleanupCron);
		}

	}

显示全文