Sharpify.Data
2.2.0
See the version list below for details.
dotnet add package Sharpify.Data --version 2.2.0
NuGet\Install-Package Sharpify.Data -Version 2.2.0
<PackageReference Include="Sharpify.Data" Version="2.2.0" />
paket add Sharpify.Data --version 2.2.0
#r "nuget: Sharpify.Data, 2.2.0"
// Install Sharpify.Data as a Cake Addin #addin nuget:?package=Sharpify.Data&version=2.2.0 // Install Sharpify.Data as a Cake Tool #tool nuget:?package=Sharpify.Data&version=2.2.0
CHANGELOG
v2.2.0
Possibly BREAKING This version changes the base types of Database
from ReadOnlyMemory<byte>
to byte[]
, apparently the change using ReadOnlyMemory<byte>
produced invalid results as if the underlying array disappeared, which left users of a empty memory which has phantom meta-data.
To ensure this doesn't happen now byte[]
is used to make sure all of the data remains, to prevent ownership issues, methods which return the actual byte[]
values, now instead return a copy (albeit an efficient one), to make sure the data integrity in the database is safe. Same goes for inserts, where previously the source was placed in the database, this might have caused it to be prematurely garbage collected, thus leaving the database with a phantom metadata, now those actions create a copy and store it instead.
- As per the issues described above and their respective solutions, memory allocations should rise in some cases, however, it is a good trade-off for ensuring absolute integrity.
- Some users mentioned that as other databases, have options to query collections, ie, returning more than 1 to 1 item per key. It could greatly improve the usability of
Database
to have such a feature. In this version the feature is introduced.TryGetValue<T>
whereT : IMemoryPackable<T>
, now haveTryGetValues
overload, which returns aT[]
, all under the same key. Respectively, an overloadUpsertMany<T>
was added with the same type restrictions. This also works fromIDatabaseFilter<T>
, these options should greatly improve useability when it comes to storing collections. - Another possibly breaking change but one required for quality of life was to rename the
string value
overloads toTryGetString
instead ofTryGetValue
, since they caused ambiguity which hindered the compilers ability to the infer the data type when usingvar
which we all love.
v2.1.0
DatabaseFilter{T}
type was changed fromreadonly struct
toclass
, and it now implements theIDatabaseFilter{T}
interface. the internalCreateKey
that in the default implementation uses the type name and:
to create a "filtered" key, is now marked as virtual. So that it is possible to inherit fromDatabaseFilter{T}
and overrideCreateKey
to either use a different template, or even add to it, for example if you have nested generics, such asTMemoryPackable<TOther>
, in which case the defaultDatabaseFilter{T}
would not be able do distinguish between the inner generic, possibly causing issues with serialization and deserialization. The change toclass
also should be costly, as the database filter can be stored as a field as well, and used similarly todbContext
of other databases. In case overridingCreateKey
is not enough, you can of course implement the wholeIDatabaseFilter{T}
interface if you so choose.Small breaking change in
DatabaseFilter{T}
, the filter will now use a:
delimiter between the type name and the key, this means you keys won't be found if were upserted using pre-change filters. This is unfortunate but necessary change in order to 1. enable better filtering of keys from theDatabase
, enabling searching and using split to get the second portion of the key. and 2. to lay the groundwork of possibly implementing more filters in the future.A temporary FIX to the breaking change in from the addition of the delimiter to
DatabaseFilter{T}
could be implemented rather easily using the new change from above, simply inherit fromDatabaseFilter{T}
, don't add anything, just override theCreateKey
function to returnstring.Concat(TName, key)
, this will behave exactly the same as the previous version ofDatabaseFilter{T}
. Nevertheless, I recommend this only as a temporary fix if you want to install the update but use existing data. at some point you should use the new feature.
DatabaseFilter{T}
was initially designed better in the context of APIs, no longer offering the Get
, but instead using TryGetValue
, while it might require 1 line of code more, when reading and writing the code, it is less ambiguous, before, a null or default result could indicate not found
, failed to deserialized
, and even upserted as null. Now if TryGetValue
returns false there can only be one reason and that is that the key did not exist.
To improve this conciseness,
Database
now hasTryGetValue
offerings, for regularReadOnlyMemory{byte}
output,IMemoryPackable{T}
andstring
. These are now the preferred APIs to use when retrieving values.The old
Get
variants ofDatabase
are now marked asDeprecated
to signal they shouldn't be used. This was made to reduce the amount of breaking changes in this version, theGet
variants will stay on asDeprecated
until the nextMajor
version, at which point they will be deleted. I hope this gives you enough time to "migrate".UpsertAsString
andUpsertAsT
(JSON version), are now also named justUpsert
, their overload is inferred from the type of the arguments as string is notIMemoryPackable{T}
and the JSONT
version requires aJsonSerializerContext
.Also added
TryGetValue
overloads for JSONT
, you will know them because they both require aJsonSerializerContext
. apparently before this version you could onlyUpsert
a JSONT
, I apologize for the oversight.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. 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 is compatible. 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. |
-
net7.0
- MemoryPack (>= 1.10.0)
- Sharpify (>= 1.7.3)
-
net8.0
- MemoryPack (>= 1.10.0)
- Sharpify (>= 1.7.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.6.0 | 79 | 11/13/2024 |
2.5.0 | 83 | 7/30/2024 |
2.4.1 | 84 | 6/3/2024 |
2.4.0 | 82 | 5/30/2024 |
2.3.0 | 125 | 4/17/2024 |
2.2.0 | 132 | 3/2/2024 |
2.1.3 | 114 | 1/25/2024 |
2.1.2 | 103 | 1/25/2024 |
2.1.1 | 107 | 1/25/2024 |
2.1.0 | 127 | 1/25/2024 |
2.0.2 | 103 | 1/23/2024 |
2.0.1 | 104 | 1/22/2024 |
2.0.0 | 99 | 1/20/2024 |
1.1.0 | 116 | 1/15/2024 |
1.0.3 | 125 | 1/8/2024 |
1.0.2 | 130 | 1/5/2024 |
1.0.1 | 124 | 1/4/2024 |
1.0.0 | 120 | 1/4/2024 |