跳到主要内容

github/tai

公开

Tai · Windows 软件与网站使用时长统计。上游 Planshit/Tai 的源码镜像,非灵栈原创;MIT 许可。来源:https://github.com/Planshit/Tai 。本次为手动同步,暂不提供安装包。

浏览文件

SiteCache.cs

42 行 · 989 B历史下载
1using Core.Models.WebPage;
2using Core.Servicers.Interfaces;
3using System;
4using System.Collections.Generic;
5using System.Linq;
6using System.Text;
7using System.Threading.Tasks;
8
9namespace Core.Librarys
10{
11 public static class SiteCache
12 {
13 private static List<Site> sites = new List<Site>();
14 private static readonly int maxNum = 100;
15 public static Site Get(string key)
16 {
17 return sites.Where(m => m.Title.Equals(key)).FirstOrDefault();
18 }
19
20 public static List<Site> GetAll()
21 {
22 return sites;
23 }
24
25 public static void Set(string key, string value)
26 {
27 if (Get(key) == null)
28 {
29 sites.Add(new Site()
30 {
31 Title = key,
32 Url = value
33 });
34
35 if (sites.Count > maxNum)
36 {
37 sites.RemoveAt(0);
38 }
39 }
40 }
41 }
42}