• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

neon-sunset / fast-cache / 11334749816

14 Oct 2024 08:43PM UTC coverage: 91.41%. Remained the same
11334749816

Pull #123

github

web-flow
Bump Microsoft.Extensions.Caching.Memory in /src/FastCache.Benchmarks

Bumps [Microsoft.Extensions.Caching.Memory](https://github.com/dotnet/runtime) from 8.0.0 to 8.0.1.
- [Release notes](https://github.com/dotnet/runtime/releases)
- [Commits](https://github.com/dotnet/runtime/compare/v8.0.0...v8.0.1)

---
updated-dependencies:
- dependency-name: Microsoft.Extensions.Caching.Memory
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #123: Bump Microsoft.Extensions.Caching.Memory from 8.0.0 to 8.0.1 in /src/FastCache.Benchmarks

339 of 418 branches covered (81.1%)

Branch coverage included in aggregate %.

1768 of 1887 relevant lines covered (93.69%)

1116.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.57
/src/FastCache.Cached/Collections/CachedRange.cs
1
using FastCache.Helpers;
2

3
namespace FastCache.Collections;
4

5
public static partial class CachedRange<V>
6
{
7
    public static void Save<K>((K, V)[] range, TimeSpan expiration) where K : notnull =>
8
        Save((ReadOnlyMemory<(K, V)>)range, expiration);
6✔
9

10
    public static void Save<K>(Memory<(K, V)> range, TimeSpan expiration) where K : notnull =>
11
        Save((ReadOnlyMemory<(K, V)>)range, expiration);
×
12

13
    public static void Save<K>(ReadOnlyMemory<(K, V)> range, TimeSpan expiration) where K : notnull
14
    {
15
        var length = range.Length;
6✔
16
        if (length <= 0)
6!
17
        {
18
            return;
×
19
        }
20

21
        var parallelism = GetParallelism((uint)length);
6✔
22
        if (parallelism > 1)
6✔
23
        {
24
            SaveMultithreaded(range, expiration, (int)parallelism);
3✔
25
        }
26
        else
27
        {
28
            SaveSinglethreaded(range, expiration);
3✔
29
        }
30
    }
3✔
31

32
    public static void Save<K>(K[] keys, V[] values, TimeSpan expiration) where K : notnull =>
33
        Save((ReadOnlyMemory<K>)keys, (ReadOnlyMemory<V>)values, expiration);
3✔
34

35
    public static void Save<K>(Memory<K> keys, Memory<V> values, TimeSpan expiration) where K : notnull =>
36
        Save((ReadOnlyMemory<K>)keys, (ReadOnlyMemory<V>)values, expiration);
×
37

38
    public static void Save<K>(ReadOnlyMemory<K> keys, ReadOnlyMemory<V> values, TimeSpan expiration) where K : notnull
39
    {
40
        var length = keys.Length;
3✔
41
        if (length < 0 || length != values.Length)
3✔
42
        {
43
            ThrowHelpers.IncorrectSaveLength(length, values.Length);
1✔
44
        }
45

46
        var parallelism = GetParallelism((uint)length);
2✔
47
        if (parallelism > 1)
2✔
48
        {
49
            SaveMultithreaded(keys, values, expiration, (int)parallelism);
1✔
50
        }
51
        else
52
        {
53
            SaveSinglethreaded(keys, values, expiration);
1✔
54
        }
55
    }
1✔
56

57
    public static void Save<K>(IList<(K, V)> range, TimeSpan expiration)
58
        where K : notnull
59
    {
60
        var length = range.Count;
2✔
61
        if (length <= 0)
2!
62
        {
63
            return;
×
64
        }
65

66
        if (range is (K, V)[] array)
2!
67
        {
68
            Save(array, expiration);
×
69
            return;
×
70
        }
71

72
        var parallelism = GetParallelism((uint)length);
2✔
73
        if (parallelism > 1)
2✔
74
        {
75
            if (range is List<(K, V)> list)
1!
76
            {
77
                SaveListMultithreaded<K, List<(K, V)>>(list, expiration, (int)parallelism);
1✔
78
            }
79
            else
80
            {
81
                SaveListMultithreaded<K, IList<(K, V)>>(range, expiration, (int)parallelism);
×
82
            }
83
        }
84
        else if (range is List<(K, V)> list)
1!
85
        {
86
            SaveListSinglethreaded<K, List<(K, V)>>(list, expiration);
1✔
87
        }
88
        else
89
        {
90
            SaveListSinglethreaded<K, IList<(K, V)>>(range, expiration);
×
91
        }
92
    }
×
93

94
    public static void Save<K>(IEnumerable<(K, V)> range, TimeSpan expiration)
95
        where K : notnull
96
    {
97
        if (range is (K, V)[] array)
6!
98
        {
99
            Save(array, expiration);
×
100
        }
101
        else if (range is IList<(K, V)> genericList)
6!
102
        {
103
            Save(genericList, expiration);
×
104
        }
105
        else if (range.TryGetNonEnumeratedCount(out var length) && GetParallelism((uint)length) > 1)
6✔
106
        {
107
            SaveEnumerableMultithreaded(range, expiration);
3✔
108
        }
109
        else
110
        {
111
            SaveEnumerableSinglethreaded(range, expiration);
3✔
112
        }
113
    }
3✔
114

115
    public static void Remove<K>(K[] keys) where K : notnull =>
116
        Remove((ReadOnlyMemory<K>)keys);
2✔
117

118
    public static void Remove<K>(Memory<K> keys) where K : notnull =>
119
        Remove((ReadOnlyMemory<K>)keys);
×
120

121
    public static void Remove<K>(ReadOnlyMemory<K> keys) where K : notnull
122
    {
123
        var parallelism = GetParallelism((uint)keys.Length);
2✔
124
        if (parallelism > 1)
2✔
125
        {
126
            RemoveMultithreaded(keys, (int)parallelism);
1✔
127
        }
128
        else
129
        {
130
            RemoveSlice(keys.Span);
1✔
131
        }
132
    }
1✔
133

134
    public static void Remove<K>(IEnumerable<K> keys) where K : notnull
135
    {
136
        if (keys is K[] array)
2!
137
        {
138
            Remove((ReadOnlyMemory<K>)array);
×
139
        }
140
        else if (keys.TryGetNonEnumeratedCount(out var count) && GetParallelism((uint)count) > 1)
2✔
141
        {
142
            var store = CacheStaticHolder<K, V>.Store;
1✔
143
            keys.AsParallel()
1✔
144
                .ForAll(key => store.TryRemove(key, out _));
4,104✔
145
        }
146
        else
147
        {
148
            var store = CacheStaticHolder<K, V>.Store;
1✔
149
            foreach (var key in keys)
2,050✔
150
            {
151
                store.TryRemove(key, out _);
1,024✔
152
            }
153
        }
154
    }
1✔
155
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc