generated from nventive/Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from nventive/dev/jpl/cache
feat: Add support for simple application caching.
- Loading branch information
Showing
15 changed files
with
1,044 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/MallardMessageHandlers.Refit/MallardMessageHandlers.Refit.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0</TargetFrameworks> | ||
<RootNamespace>MallardMessageHandlers</RootNamespace> | ||
<Authors>nventive</Authors> | ||
<Company>nventive</Company> | ||
<AssemblyName>MallardMessageHandlers.Refit</AssemblyName> | ||
<PackageId>MallardMessageHandlers.Refit</PackageId> | ||
<Description>MallardMessageHandlers.Refit</Description> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<LangVersion>10</LangVersion> | ||
<PackageTags>delegatinghandler;oauth;network-status;network;networkexception;authenticationtoken;exceptioninterpreter;exceptionhub;refit</PackageTags> | ||
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression> | ||
<PackageProjectUrl>https://github.com/nventive/MallardMessageHandlers</PackageProjectUrl> | ||
<PackageReadmeFile>README.md</PackageReadmeFile> | ||
|
||
<!--Needed for Source Link support --> | ||
<PublishRepositoryUrl>true</PublishRepositoryUrl> | ||
<EmbedUntrackedSources>true</EmbedUntrackedSources> | ||
<IncludeSymbols>true</IncludeSymbols> | ||
<SymbolPackageFormat>snupkg</SymbolPackageFormat> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Include="..\..\README.md"> | ||
<Pack>True</Pack> | ||
<PackagePath>\</PackagePath> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Refit" Version="6.0.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<!--Needed for Source Link support --> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\MallardMessageHandlers\MallardMessageHandlers.csproj" /> | ||
</ItemGroup> | ||
</Project> |
62 changes: 62 additions & 0 deletions
62
src/MallardMessageHandlers.Refit/SimpleCaching/RefitAttributes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Refit; | ||
|
||
namespace MallardMessageHandlers.SimpleCaching | ||
{ | ||
/// <summary> | ||
/// Sets the cache time-to-live for the current call. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Method)] | ||
public class TimeToLiveAttribute : HeadersAttribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="TimeToLiveAttribute"/> class. | ||
/// </summary> | ||
/// <param name="totalSeconds">The time-to-live in seconds.</param> | ||
public TimeToLiveAttribute(int totalSeconds) | ||
: base(SimpleCacheHandler.CacheTimeToLiveHeaderName + ":" + totalSeconds) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="TimeToLiveAttribute"/> class. | ||
/// </summary> | ||
/// <param name="totalMinutes">The time-to-live in minutes.</param> | ||
public TimeToLiveAttribute(double totalMinutes) | ||
: base(SimpleCacheHandler.CacheTimeToLiveHeaderName + ":" + (int)(totalMinutes * 60)) | ||
{ | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Bypasses the other simple caching instructions. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Method)] | ||
public class NoCacheAttribute : HeadersAttribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="NoCacheAttribute"/> class. | ||
/// </summary> | ||
public NoCacheAttribute() | ||
: base(SimpleCacheHandler.CacheDisableHeaderName + ":true") | ||
{ | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Associates the force-refresh simple caching instruction with a boolean parameter. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Parameter)] | ||
public class ForceRefresh : HeaderAttribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ForceRefresh"/> class. | ||
/// </summary> | ||
public ForceRefresh() | ||
: base(SimpleCacheHandler.CacheForceRefreshHeaderName) | ||
{ | ||
} | ||
} | ||
} |
Oops, something went wrong.