Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .autover/changes/dd27e0cc-00fb-4dc0-b9c4-92b2ddea42c2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"Projects": [
{
"Name": "AWS.AspNetCore.DistributedCacheProvider",
"Type": "Major",
"ChangelogMessages": [
"Updated the .NET SDK dependencies to the latest version 4.0.0-preview.4",
"Marked project as trimmable",
"Added SourceLink support"
]
}
]
}
16 changes: 11 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# Changelog
## Release 2024-04-20

## 0.9.3 (2024-04-20)
### AWS.AspNetCore.DistributedCacheProvider (0.9.3)
- Update User-Agent string

## 0.9.2 (2023-07-28)
## Release 2023-07-28

### AWS.AspNetCore.DistributedCacheProvider (0.9.2)
- Add PackageReadmeFile attribute to show README file in NuGet

## 0.9.1 (2023-07-28)
## Release 2023-07-28

### AWS.AspNetCore.DistributedCacheProvider (0.9.1)
- Added the repository README file to the NuGet package

## 0.9.0 (2023-07-06)
## Release 2023-07-06

### AWS.AspNetCore.DistributedCacheProvider (0.9.0)
- Initial preview release
36 changes: 36 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,42 @@ To send us a pull request, please:
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).

## Adding a `change file` to your contribution branch
Each contribution branch should include a `change file` that contains a changelog message for each project that has been updated, as well as the type of increment to perform for those changes when versioning the project.
A `change file` looks like the following example:
```json
{
"Projects": [
{
"Name": "AWS.AspNetCore.DistributedCacheProvider",
"Type": "Patch",
"ChangelogMessages": [
"Fixed an issue causing a failure somewhere"
]
}
]
}
```
The `change file` lists all the modified projects, the changelog message for each project as well as the increment type.
These files are located in the repo at .autover/changes/
You can use the `AutoVer` tool to create the change file. You can install it using the following command:
```
dotnet tool install -g AutoVer
```
You can create the `change file` using the following command:
```
autover change --project-name "AWS.AspNetCore.DistributedCacheProvider" -m "Fixed an issue causing a failure somewhere
```
Note: Make sure to run the command from the root of the repository.
You can update the command to specify which project you are updating.
The available projects are:
* AWS.AspNetCore.DistributedCacheProvider
The possible increment types are:
* Patch
* Minor
* Major
Note: You do not need to create a new `change file` for every changelog message or project within your branch. You can create one `change file` that contains all the modified projects and the changelog messages.


## Finding contributions to work on
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start.
Expand Down
2 changes: 1 addition & 1 deletion SampleApp/SampleApp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion buildtools/ci.buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 0.2
phases:
install:
runtime-versions:
dotnet: 6.x
dotnet: 8.x
build:
commands:
- dotnet test --verbosity normal AWS.DistributedCacheProvider.sln --configuration Release --logger trx --results-directory ./testresults
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<RootNamespace>AWS.DistributedCacheProvider</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.9.3</Version>
<Version>2.0.0-preview.1</Version>
<PackageId>AWS.AspNetCore.DistributedCacheProvider</PackageId>
<Title>AWS Provider for ASP.NET Core's IDistributedCache</Title>
<Description>The AWS Distributed Cache provider provides an IDistributedCache implementation backed by DynamoDB.</Description>
Expand All @@ -20,7 +20,16 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\public.snk</AssemblyOriginatorKeyFile>

<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReadmeFile>README.md</PackageReadmeFile>

<EmbedUntrackedSources>true</EmbedUntrackedSources>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>

<ItemGroup>
Expand All @@ -35,8 +44,9 @@
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.302.15" />
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="3.7.300" />
<PackageReference Include="AWSSDK.DynamoDBv2" Version="4.0.0-preview.4" />
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="4.0.0-preview.4" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
</ItemGroup>

</Project>
8 changes: 6 additions & 2 deletions src/AWS.DistributedCacheProvider/DynamoDBDistributedCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,6 @@ private DateTimeOffset UnixSecondsToDateTimeOffset(string seconds)
return DateTimeOffset.FromUnixTimeSeconds((long)double.Parse(seconds));
}



/// <summary>
/// Retrieves the value associated with <paramref name="key"/> in the cache and updates the Item's TTL.
/// If there is no value associated with the <paramref name="key"/> or there is a value, but the Item's TTL
Expand Down Expand Up @@ -429,6 +427,12 @@ private DateTimeOffset UnixSecondsToDateTimeOffset(string seconds)
throw new DynamoDBDistributedCacheException($"Failed to get Item with key {key}. Caused by {e.Message}", e);
}

if (getItemResponse.Item is null)
{
_logger.LogDebug("DynamoDB did not find an Item associated with the key {key}", key);
return null;
}

//Check if there is a value we should be returning to the client. If there is no value, there is no reason to refresh the Item
if (getItemResponse.Item.ContainsKey(VALUE_KEY))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static AttributeValue CalculateTTL(DistributedCacheEntryOptions options)
var ttl = DateTimeOffset.UtcNow.Add(((TimeSpan)options.SlidingExpiration));
//Cannot be later than the deadline
var absoluteTTL = CalculateTTLDeadline(options);
if (absoluteTTL.NULL)
if (absoluteTTL.NULL is not null && (bool)absoluteTTL.NULL)
{
return new AttributeValue { N = ttl.ToUnixTimeSeconds().ToString() };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public async Task<string> CreateTableIfNotExistsAsync(IAmazonDynamoDB client, st
private string ValidateTable(TableDescription description)
{
var partitionKeyName = "";
foreach (var key in description.KeySchema)
var keySchema = description.KeySchema ?? new List<KeySchemaElement>();
foreach (var key in keySchema)
{
if (key.KeyType.Equals(KeyType.RANGE))
{
Expand All @@ -81,7 +82,8 @@ private string ValidateTable(TableDescription description)
}
else //We know the key is of type Hash
{
foreach (var attributeDef in description.AttributeDefinitions)
var attributeDefinitions = description.AttributeDefinitions ?? new List<AttributeDefinition>();
foreach (var attributeDef in attributeDefinitions)
{
if (attributeDef.AttributeName.Equals(key.AttributeName) && attributeDef.AttributeType != ScalarAttributeType.S)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.302.15" />
<PackageReference Include="AWSSDK.SecurityToken" Version="3.7.300.75" />
<PackageReference Include="AWSSDK.DynamoDBv2" Version="4.0.0-preview.4" />
<PackageReference Include="AWSSDK.SecurityToken" Version="4.0.0-preview.4" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="xunit" Version="2.4.2" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public void CalculateTTL_NoSlidingWindow_ReturnDeadline()
};
var deadline = DynamoDBCacheProviderHelper.CalculateTTLDeadline(options);
var ttl = DynamoDBCacheProviderHelper.CalculateTTL(options);
Assert.False(deadline.NULL);
Assert.False(ttl.NULL);
Assert.Null(deadline.NULL);
Assert.Null(ttl.NULL);
Assert.Equal(ttl.N, deadline.N);
}

Expand Down
Loading