创建循环队列的最佳策略

时间:2018-06-15 17:24:08

标签: c# algorithm asp.net-core .net-core

我想创建一个循环队列,对于向服务器发出的每个请求,队列中的新值将被发送,然后移动到队列的后面。

但是我有一个可能不起作用的实现,请参阅下文:

系统是带有单个get(GetValue)的web api(ASP.net Core 2),这应该返回从队列中拉出的简单字符串;

我将所有值保存在本地SQLite数据库中,该数据库由后台进程填充,后台进程从外部源获取所有值;

我最初的想法是拥有一个包含这些字段的数据库:

public int Id { get; set; }

//Value that will be sent via get
public string Value { get; set; }

//How many time this value was sent (Would increment every time the value is selected to be sent)
public int Requests { get; set; }

//When was the last time the value was sent
public DateTime LastRequested { get; set; }

//When was it loaded to the local database from external source
public DateTime Added { get; set; }

//If value is active
public bool IsActive { get; set; }

然后进行查询以选择应该发送的值,例如

valuesList.Where(x => x.isActive == true).OrderByDesc(x => x.LastRequested)

但是新值具有更高的优先级,并且应该在查询中排名更高的3个选项和每次一些

有关如何解决此问题的任何建议?

0 个答案:

没有答案
相关问题