-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
35 lines (32 loc) · 1.03 KB
/
Program.cs
File metadata and controls
35 lines (32 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
namespace timebased_key_value_store
{
class Program
{
static void Main()
{
var store = new TimeBasedKeyValueStore();
// Add a value with a key, data, and expiry time in minutes
store.Put("myKey", 42, 30);
// Retrieve a value by key (within the specified expiry time)
var retrievedValue = store.Get("myKey", 20);
if (retrievedValue.HasValue)
{
Console.WriteLine($"Value for 'myKey': {retrievedValue}");
}
else
{
Console.WriteLine("Value not found or expired.");
}
// Calculate the average of non-expired values within a time window
var average = store.Average(60);
if (average.HasValue)
{
Console.WriteLine($"Average value: {average}");
}
else
{
Console.WriteLine("No valid values in the specified time window.");
}
}
}
}