mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
Cache tweaks
This commit is contained in:
@@ -6,6 +6,7 @@ using Espresso.Shell.Core;
|
|||||||
using Espresso.Shell.Models;
|
using Espresso.Shell.Models;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Specialized;
|
||||||
using System.CommandLine;
|
using System.CommandLine;
|
||||||
using System.CommandLine.Invocation;
|
using System.CommandLine.Invocation;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -23,7 +24,7 @@ namespace Espresso.Shell
|
|||||||
|
|
||||||
private static MemoryCache _memoryCache;
|
private static MemoryCache _memoryCache;
|
||||||
private static CacheItemPolicy _cacheItemPolicy;
|
private static CacheItemPolicy _cacheItemPolicy;
|
||||||
private const int CacheExpirationTimeframe = 500;
|
private const int CacheExpirationTimeframe = 1000;
|
||||||
|
|
||||||
static int Main(string[] args)
|
static int Main(string[] args)
|
||||||
{
|
{
|
||||||
@@ -109,7 +110,12 @@ namespace Espresso.Shell
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_memoryCache = MemoryCache.Default;
|
var cacheConfig = new NameValueCollection()
|
||||||
|
{
|
||||||
|
{"CacheMemoryLimitMegabytes", "1"},
|
||||||
|
{"PollingInterval", TimeSpan.FromMilliseconds(1000).ToString()},
|
||||||
|
};
|
||||||
|
_memoryCache = new MemoryCache("EventCache", cacheConfig);
|
||||||
|
|
||||||
watcher = new FileSystemWatcher
|
watcher = new FileSystemWatcher
|
||||||
{
|
{
|
||||||
@@ -174,7 +180,7 @@ namespace Espresso.Shell
|
|||||||
private static void HandleEspressoConfigChange(object sender, FileSystemEventArgs e)
|
private static void HandleEspressoConfigChange(object sender, FileSystemEventArgs e)
|
||||||
{
|
{
|
||||||
_cacheItemPolicy.AbsoluteExpiration = DateTimeOffset.Now.AddMilliseconds(CacheExpirationTimeframe);
|
_cacheItemPolicy.AbsoluteExpiration = DateTimeOffset.Now.AddMilliseconds(CacheExpirationTimeframe);
|
||||||
_memoryCache.AddOrGetExisting(e.Name, e, _cacheItemPolicy);
|
_memoryCache.Set(e.Name, e, _cacheItemPolicy);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ProcessSettings(string fullPath)
|
private static void ProcessSettings(string fullPath)
|
||||||
|
|||||||
Reference in New Issue
Block a user