Skip to content

Commit fa34674

Browse files
committed
Update InMemoryStickySessionStorage.cs
Use File-scoped namespace declaration
1 parent 37b2ce2 commit fa34674

File tree

1 file changed

+32
-33
lines changed

1 file changed

+32
-33
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
11
using System.Collections.Concurrent;
22

3-
namespace Ocelot.LoadBalancer.LoadBalancers
3+
namespace Ocelot.LoadBalancer.LoadBalancers;
4+
5+
public class InMemoryStickySessionStorage : IStickySessionStorage
46
{
5-
public class InMemoryStickySessionStorage : IStickySessionStorage
7+
private readonly ConcurrentDictionary<string, StickySession> _storage;
8+
9+
public InMemoryStickySessionStorage()
10+
{
11+
_storage = new ConcurrentDictionary<string, StickySession>();
12+
}
13+
14+
public bool TryGetSession(string key, out StickySession session)
15+
{
16+
return _storage.TryGetValue(key, out session);
17+
}
18+
19+
public StickySession GetSession(string key)
20+
{
21+
return _storage.TryGetValue(key, out var session) ? session : null;
22+
}
23+
24+
public void SetSession(string key, StickySession session)
25+
{
26+
_storage[key] = session;
27+
}
28+
29+
public bool TryRemove(string key, out StickySession session)
30+
{
31+
return _storage.TryRemove(key, out session);
32+
}
33+
34+
public bool Contains(string key)
635
{
7-
private readonly ConcurrentDictionary<string, StickySession> _storage;
8-
9-
public InMemoryStickySessionStorage()
10-
{
11-
_storage = new ConcurrentDictionary<string, StickySession>();
12-
}
13-
14-
public bool TryGetSession(string key, out StickySession session)
15-
{
16-
return _storage.TryGetValue(key, out session);
17-
}
18-
19-
public StickySession GetSession(string key)
20-
{
21-
return _storage.TryGetValue(key, out var session) ? session : null;
22-
}
23-
24-
public void SetSession(string key, StickySession session)
25-
{
26-
_storage[key] = session;
27-
}
28-
29-
public bool TryRemove(string key, out StickySession session)
30-
{
31-
return _storage.TryRemove(key, out session);
32-
}
33-
34-
public bool Contains(string key)
35-
{
36-
return _storage.ContainsKey(key);
37-
}
36+
return _storage.ContainsKey(key);
3837
}
3938
}

0 commit comments

Comments
 (0)