简体   繁体   English

MySQL 基于表大小的FIFO策略

[英]MySQL FIFO policy based on table size

I have a table in MySQL where arrive continuously data (these data have a timestamp).我在 MySQL 中有一个表,其中连续到达数据(这些数据有时间戳)。 I'd like to create a FIFO Queue based on the size of the table.我想根据表的大小创建一个 FIFO 队列。 I mean, if I set for example 1GB as threshold and the data begin to be stored once I reach 1 GB of capacity I start to delete data in a fifo way.我的意思是,如果我将 1GB 设置为阈值,并且一旦达到 1GB 的容量就开始存储数据,我将开始以 fifo 方式删除数据。 Anyone have any suggestions or have ever done anything similar?任何人有任何建议或曾经做过类似的事情吗?

Thank you谢谢

I think you are confused on the definition of a FIFO queue.我认为您对 FIFO 队列的定义感到困惑。 You don't describe any consumer of the queue, only deletions.您不描述队列的任何消费者,只描述删除。

It sounds more like a least-recently-used cache, that holds up to 1GB of data, but the "oldest" data is overwritten as new data is inserted.这听起来更像是最近最少使用的缓存,最多可容纳 1GB 的数据,但“最旧”的数据会随着新数据的插入而被覆盖。

MySQL is neither a cache nor a queue. MySQL 既不是缓存也不是队列。 MySQL is a database. MySQL 是一个数据库。 It is designed to store all the data you insert into it, durably.它旨在持久存储您插入其中的所有数据。 It has no feature to do automatic deletion.它没有自动删除的功能。

I suggest you should use a cache server such as redis. It has the feature you are looking for, to evict data if the collection exceeds a fixed size.我建议你应该使用缓存服务器,如 redis。它具有你正在寻找的功能,如果集合超过固定大小,则驱逐数据。

See the post: Using Redis as an LRU cache见帖子: Using Redis as an LRU cache

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM