mysql - Record the last newly added ID in PHP
習慣沉默
習慣沉默 2017-05-16 13:12:21
0
2
584

I want to save and download the record ID last inserted into the database, and read it again when the download method is called. After inserting, the original record ID is overwritten. How to achieve better performance? Save to database? Save to file? Will the cache be flushed?

習慣沉默
習慣沉默

reply all(2)
某草草

Recursive algorithm fits this business

为情所困

If there is redis或者memcache作为缓存的话设置key永不过期可以解决(redis可持久化数据,但不排除宕机后丢失),每次插入后更新值,相对性能较好,保存数据库和文件也可以解决问题,也可以两者同时使用,既保存到数据库又放入缓存,更新时增加成本但可靠性更好,也可以换种思路,每次去数据库查询,对于innodb引擎的mysql数据表,主键查询效率较高,idIt is also a good solution to take the first one in reverse order. If a connection pool is used, the performance will be better.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template