@@ -13,11 +13,11 @@ namespace Uchu.World.Client
13
13
/// </summary>
14
14
public class TableCache < T > where T : class
15
15
{
16
- private PropertyInfo cdClientContextProperty ;
17
- private T [ ] cachedData ;
18
- private long lastAccessTime = 0 ;
19
- private bool clearDataQueued = false ;
20
- private int clearTimeMilliseconds = 3000 ;
16
+ private PropertyInfo CdClientContextProperty ;
17
+ private T [ ] CachedData ;
18
+ private long LastAccessTime = 0 ;
19
+ private bool ClearDataQueued = false ;
20
+ private int ClearTimeMilliseconds = 3000 ;
21
21
22
22
/// <summary>
23
23
/// Creates the table cache.
@@ -28,12 +28,12 @@ public TableCache(string tableName)
28
28
foreach ( var property in typeof ( CdClientContext ) . GetProperties ( ) )
29
29
{
30
30
if ( property . Name != tableName ) continue ;
31
- cdClientContextProperty = property ;
31
+ CdClientContextProperty = property ;
32
32
break ;
33
33
}
34
34
35
35
// Throw an exception if the table name is invalid.
36
- if ( cdClientContextProperty == null )
36
+ if ( CdClientContextProperty == null )
37
37
{
38
38
throw new InvalidOperationException ( "Table name doesn't exist: " + tableName ) ;
39
39
}
@@ -45,23 +45,23 @@ public TableCache(string tableName)
45
45
public async Task < T [ ] > GetValuesAsync ( )
46
46
{
47
47
// Update the last access time and fetch the data if it isn't stored.
48
- lastAccessTime = DateTimeOffset . Now . ToUnixTimeSeconds ( ) ;
49
- if ( cachedData == default )
48
+ LastAccessTime = DateTimeOffset . Now . ToUnixTimeSeconds ( ) ;
49
+ if ( CachedData == default )
50
50
{
51
51
// Fetch the data.
52
52
await using var cdContext = new CdClientContext ( ) ;
53
- cachedData = ( ( DbSet < T > ) cdClientContextProperty . GetValue ( cdContext ) ) ? . ToArray ( ) ;
53
+ CachedData = ( ( DbSet < T > ) CdClientContextProperty . GetValue ( cdContext ) ) ? . ToArray ( ) ;
54
54
55
55
// Queue clearing the data.
56
- if ( ! clearDataQueued )
56
+ if ( ! ClearDataQueued )
57
57
{
58
- clearDataQueued = true ;
58
+ ClearDataQueued = true ;
59
59
Task . Run ( ClearQueueTimeAsync ) ;
60
60
}
61
61
}
62
62
63
63
// Return the cached data.
64
- return cachedData ;
64
+ return CachedData ;
65
65
}
66
66
67
67
/// <summary>
@@ -73,13 +73,13 @@ private async void ClearQueueTimeAsync()
73
73
while ( true )
74
74
{
75
75
// Wait the delay before checking to clear the table.
76
- var startLastAccessTime = lastAccessTime ;
77
- await Task . Delay ( clearTimeMilliseconds ) ;
76
+ var startLastAccessTime = LastAccessTime ;
77
+ await Task . Delay ( ClearTimeMilliseconds ) ;
78
78
79
79
// Clear the table if it hasn't been accessed recently.
80
- if ( startLastAccessTime != lastAccessTime ) continue ;
81
- cachedData = default ;
82
- clearDataQueued = false ;
80
+ if ( startLastAccessTime != LastAccessTime ) continue ;
81
+ CachedData = default ;
82
+ ClearDataQueued = false ;
83
83
GC . Collect ( ) ;
84
84
return ;
85
85
}
0 commit comments