magic.lambda.caching
10.0.7
See the version list below for details.
dotnet add package magic.lambda.caching --version 10.0.7
NuGet\Install-Package magic.lambda.caching -Version 10.0.7
<PackageReference Include="magic.lambda.caching" Version="10.0.7" />
paket add magic.lambda.caching --version 10.0.7
#r "nuget: magic.lambda.caching, 10.0.7"
// Install magic.lambda.caching as a Cake Addin #addin nuget:?package=magic.lambda.caching&version=10.0.7 // Install magic.lambda.caching as a Cake Tool #tool nuget:?package=magic.lambda.caching&version=10.0.7
Magic Lambda Caching
Cache helper slots for Magic, more specifically the following slots.
- [cache.set] - Adds the specified item to the cache.
- [cache.get] - Returns a previously cached item, if existing.
- [cache.try-get] - Attempts to retrieve an item from cache, and if not existing, invokes [.lambda] to retrieve item, and saves it to cache, before returning it to the caller.
- [cache.clear] - Completely empties cache.
- [cache.list] - Lists all items in cache.
- [cache.count] - Returns the number of cache items in total.
All of the above slots requires a key as its value, and/or a [filter] argument.
[cache.set]
Invoke this slot to save an item to the cache. The slot takes 3 properties, which are as follows.
- Value of node, being the key for your cache item.
- [value] - The item to actually save to the cache. If you pass in null, any existing cache items matching your key will be removed.
- [expiration] - Number of seconds to keep the item in the cache.
Below is an example of a piece of Hyperlambda that simply saves the value of "Howdy world" to your cache, using "cache-item-key" as the key for the cache item.
cache.set:cache-item-key
expiration:5
value:Howdy world
To remove the above item, you can use the following Hyperlambda.
cache.set:cache-item-key
[cache.get]
Returns an item from your cache, or null if there are no items matching the specified key. Below is an example of retrieving the item we saved to the cache above.
cache.get:cache-item-key
[cache.try-get]
This slot checks your cache to look for an item matching your specified key, and if not found, it will invoke its [.lambda] argument, and save its returned value to the cache with the specified key, before returning the value to caller. This is a particularly useful slot, since it will synchronise access to the cache key, preventing more than one lambda object from being invoked simultaneously, given the same key.
cache.try-get:cache-key
expiration:5
.lambda
return:Howdy world
The slot is implemented in such a way that only the first invocation towards the specified key will actually execute your [.lambda] object, allowing you to have very expensive executions to create your items, that you want to store into the cache, without experiencing race conditions, or having more than one thread actually create the item and store into the cache. This should in general be your "goto slot" whenever you want to use the cache slots in this project.
[cache.clear]
This is a shorthand slot to completely clear cache, removing all items.
cache.set:cache-item-key
expiration:5
value:Howdy world
cache.clear
cache.get:cache-item-key
Notice, the above Hyperlambda should not return any item in its last invocation to [cache.get] since the cache was cleared before invoking it. The slot also optionally takes a [filter] argument, which if provided, will only delete items starting out with the specified filter. Usage example can be found below.
cache.clear
filter:foo.bar
The above will only remove cache items having a key that starts out with "foo.bar" implying that for instance the following items will be cleared.
- foo.bar
- foo.bar.xyz1
- foo.bar.xyz2
While an item with a key of "x.foo.bar" will not be removed. This allows you to "namespace" your cache items, and clearing out for instance all cache items matching the specified namespace, in one go. You can optionally supply the clearing filter as the value of the node, such as the following illustrates.
cache.clear:foo.bar
[cache.list]
Lists all items in cache, and returns to caller.
cache.set:cache-item-key
expiration:5
value:Howdy world
cache.list
This slot also supports the following optional arguments.
- [limit] - Maximum number of items to return.
- [offset] - Offset of where to start returning items.
- [filter] - Filter condition declaring which items to return. See the [cache.clear] slot to understand how it works, since this argument functions in the exact same way, assuming your filter is a "namespace".
The [filter] argument can optionally be supplied as the value of the node such as the following illustrates.
cache.set:cache-item-key
expiration:5
value:Howdy world
cache.list:cache
Internals
Internally the cache this project is using is not the MemoryCache
from .Net, since this class
suffers from a whole range of problems in regards to its API, such as not being able to count or
iterate items, etc. Hence, the actual implementation is completely custom, and is based upon
the IMagicCache
interface, which by default is wired up towards its MagicMemoryCache
implementation. This is a conscious choice, since first of all the IMemoryCache
that .Net
provides out of the box is really slow, in addition to that it is missing a lot of crucial
parts expected from a mature memory based cache implementation.
If you want to access the actual cache from C# or something, make sure you use it through the dependency
injected IMagicCache
interface, providing you with the implementation class needed to consume
it from C#. This interface has a lot of nice methods you can use to have a robust and fast memory
based cache implementation in your C# code - In addition to that it synchronises access such that
no race conditions can be experienced. However, it is a memory based cache. If you need better
caching features going beyond what a basic memory based cache implementation can achieve, you might
want to implement Redis or something similar as your own custom C# extension.
Notice, if you consume the IMagicCache
interface from your own C# code, you can create "hidden"
cache items that are only possible to retrieve from C# code and not from Hyperlambda. This allows
you to create a C# only type of cache, where items added as hidden cannot in any ways what so ever
be retrieved from Hyperlambda. This is useful for C# only type of cache items, you don't want to expose
to Hyperlambda code.
Project website
The source code for this repository can be found at github.com/polterguy/magic.lambda.caching, and you can provide feedback, provide bug reports, etc at the same place.
Quality gates
License
This project is the copyright(c) 2020-2021 of Aista, Ltd thomas@servergardens.com, and is licensed under the terms of the LGPL version 3, as published by the Free Software Foundation. See the enclosed LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- magic.node.extensions (>= 10.0.7)
- magic.signals.contracts (>= 10.0.7)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on magic.lambda.caching:
Package | Downloads |
---|---|
magic.library
Helper project for Magic to wire up everything easily by simply adding one package, and invoking two simple methods. When using Magic, this is (probably) the only package you should actually add, since this package pulls in everything else you'll need automatically, and wires up everything sanely by default. To use package go to https://polterguy.github.io |
|
magic.lambda.slots
Helper slots for Magic, to allow you to dynamically create dynamic slots in your own Hyperlambda. To use package go to https://polterguy.github.io |
|
magic.data.cql
CQL data adapters for Magic to store files and folders, etc. To use package go to https://polterguy.github.io |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
17.2.0 | 526 | 1/22/2024 |
17.1.7 | 246 | 1/12/2024 |
17.1.6 | 215 | 1/11/2024 |
17.1.5 | 230 | 1/5/2024 |
17.0.1 | 278 | 1/1/2024 |
17.0.0 | 419 | 12/14/2023 |
16.11.5 | 434 | 11/12/2023 |
16.9.0 | 440 | 10/9/2023 |
16.7.0 | 658 | 7/11/2023 |
16.4.1 | 502 | 7/2/2023 |
16.4.0 | 483 | 6/22/2023 |
16.3.1 | 461 | 6/7/2023 |
16.3.0 | 431 | 5/28/2023 |
16.1.9 | 766 | 4/30/2023 |
15.10.11 | 618 | 4/13/2023 |
15.9.1 | 746 | 3/26/2023 |
15.9.0 | 617 | 3/24/2023 |
15.8.2 | 711 | 3/20/2023 |
15.7.0 | 596 | 3/6/2023 |
15.5.0 | 2,001 | 1/28/2023 |
15.2.0 | 1,062 | 1/18/2023 |
15.1.0 | 1,548 | 12/28/2022 |
14.5.7 | 1,122 | 12/13/2022 |
14.5.5 | 1,233 | 12/6/2022 |
14.5.1 | 1,121 | 11/23/2022 |
14.5.0 | 1,108 | 11/18/2022 |
14.4.5 | 1,268 | 10/22/2022 |
14.4.1 | 1,295 | 10/22/2022 |
14.4.0 | 1,197 | 10/17/2022 |
14.3.1 | 1,862 | 9/12/2022 |
14.3.0 | 1,224 | 9/10/2022 |
14.1.3 | 1,535 | 8/7/2022 |
14.1.2 | 1,242 | 8/7/2022 |
14.1.1 | 1,262 | 8/7/2022 |
14.0.14 | 1,321 | 7/26/2022 |
14.0.12 | 1,290 | 7/24/2022 |
14.0.11 | 1,204 | 7/23/2022 |
14.0.10 | 1,204 | 7/23/2022 |
14.0.9 | 1,233 | 7/23/2022 |
14.0.8 | 1,356 | 7/17/2022 |
14.0.5 | 1,394 | 7/11/2022 |
14.0.4 | 1,430 | 7/6/2022 |
14.0.3 | 1,315 | 7/2/2022 |
14.0.2 | 1,246 | 7/2/2022 |
14.0.0 | 1,739 | 6/25/2022 |
13.4.0 | 2,633 | 5/31/2022 |
13.3.4 | 2,024 | 5/9/2022 |
13.3.0 | 1,790 | 5/1/2022 |
13.2.0 | 1,832 | 4/21/2022 |
13.1.0 | 1,680 | 4/7/2022 |
13.0.0 | 1,333 | 4/5/2022 |
11.0.5 | 2,346 | 3/2/2022 |
11.0.4 | 1,361 | 2/22/2022 |
11.0.3 | 1,394 | 2/9/2022 |
11.0.2 | 1,417 | 2/6/2022 |
11.0.1 | 542 | 2/5/2022 |
11.0.0 | 1,436 | 2/5/2022 |
10.0.21 | 1,406 | 1/28/2022 |
10.0.20 | 1,074 | 1/27/2022 |
10.0.19 | 1,099 | 1/23/2022 |
10.0.18 | 1,050 | 1/17/2022 |
10.0.15 | 1,186 | 12/31/2021 |
10.0.14 | 813 | 12/28/2021 |
10.0.8 | 1,442 | 12/22/2021 |
10.0.7 | 766 | 12/22/2021 |
10.0.5 | 746 | 12/18/2021 |
9.9.9 | 1,702 | 11/29/2021 |
9.9.3 | 912 | 11/9/2021 |
9.9.2 | 620 | 11/4/2021 |
9.9.0 | 750 | 10/30/2021 |
9.8.9 | 718 | 10/29/2021 |
9.8.7 | 689 | 10/27/2021 |
9.8.6 | 644 | 10/27/2021 |
9.8.5 | 719 | 10/26/2021 |
9.8.0 | 1,387 | 10/20/2021 |
9.7.9 | 670 | 10/19/2021 |
9.7.5 | 1,486 | 10/14/2021 |
9.7.0 | 868 | 10/9/2021 |
9.6.6 | 1,241 | 8/14/2021 |
9.2.0 | 6,236 | 5/26/2021 |
9.1.4 | 1,279 | 4/21/2021 |
9.1.0 | 1,075 | 4/14/2021 |
9.0.0 | 840 | 4/5/2021 |
8.9.9 | 1,010 | 3/30/2021 |
8.9.3 | 1,544 | 3/19/2021 |
8.9.2 | 1,043 | 1/29/2021 |
8.9.1 | 1,024 | 1/24/2021 |
8.9.0 | 1,121 | 1/22/2021 |
8.6.9 | 2,929 | 11/8/2020 |
8.6.6 | 1,947 | 11/2/2020 |
8.6.2 | 2,570 | 10/30/2020 |
8.6.0 | 2,016 | 10/28/2020 |
8.5.0 | 1,889 | 10/23/2020 |
8.4.0 | 5,469 | 10/13/2020 |
8.3.1 | 2,624 | 10/5/2020 |
8.3.0 | 1,278 | 10/3/2020 |
8.2.2 | 2,031 | 9/26/2020 |
8.2.1 | 1,356 | 9/25/2020 |
8.2.0 | 1,376 | 9/25/2020 |
8.1.17 | 6,567 | 9/13/2020 |
8.1.16 | 643 | 9/13/2020 |
8.1.15 | 1,882 | 9/12/2020 |
8.1.11 | 2,474 | 9/11/2020 |
8.1.10 | 1,290 | 9/6/2020 |
8.1.9 | 1,314 | 9/3/2020 |
8.1.8 | 1,319 | 9/2/2020 |