如何更好地实现网站更新状态的需求?
我有这样一个需求。
有一系列的项目,这些项目分别由使用用户与审核人员操作。
用户添加一个项目A,审核人员审核项目A,这时候状态会随之更新。
但是有些状态,它不是实时修改的。比方说,这个项目A有一个状态修改的触发时间,到了这个时间点,项目A就会自动的改变状态。
我现在是每次打开项目时,都去查一下有哪些符合条件可以修改状态的时间点,如果找到了,就去修改它的状态。这样做的效率很低,因为项目一多,列表就打开很慢。
我想请问各位有没有更好的方法,在项目有很多状态的情况下,实现触发修改。
回复内容:
我有这样一个需求。
有一系列的项目,这些项目分别由使用用户与审核人员操作。
用户添加一个项目A,审核人员审核项目A,这时候状态会随之更新。
但是有些状态,它不是实时修改的。比方说,这个项目A有一个状态修改的触发时间,到了这个时间点,项目A就会自动的改变状态。
我现在是每次打开项目时,都去查一下有哪些符合条件可以修改状态的时间点,如果找到了,就去修改它的状态。这样做的效率很低,因为项目一多,列表就打开很慢。
我想请问各位有没有更好的方法,在项目有很多状态的情况下,实现触发修改。
有简单的方法,也有复杂的方法。
简单的,写个定时器,利用定时器程序去过呢关心,定期执行程序检查项目是否到了时间点,这样就能把更新操作和你打开项目的操作解耦。
复杂点的,消息队列,特别是复杂系统里面,一个事件的更新,可能会引起多个数据的联动修改。那么主事件触发后,会往消息队列中放一条消息,多个消息监听者收到消息后,会各自处理自己相关的信息数据。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.
