Skip to content
Open
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 .idea/.idea.DynaCache/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/.idea.DynaCache/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/.idea.DynaCache/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/.idea.DynaCache/.idea/riderModule.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/.idea.DynaCache/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 0 additions & 61 deletions DynaCache.AspNetCache/AspNetCacheService.cs

This file was deleted.

71 changes: 0 additions & 71 deletions DynaCache.AspNetCache/DynaCache.AspNetCache.csproj

This file was deleted.

10 changes: 0 additions & 10 deletions DynaCache.AspNetCache/DynaCache.AspNetCache.csproj.vspscc

This file was deleted.

11 changes: 0 additions & 11 deletions DynaCache.AspNetCache/Properties/AssemblyInfo.cs

This file was deleted.

18 changes: 18 additions & 0 deletions DynaCache.Core.MemoryCache/DynaCache.Core.MemoryCache.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>DynaCache.MemoryCache</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\DynaCache.Core\DynaCache.Core.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
<PackageReference Include="System.Runtime.Caching" Version="5.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using DynaCache.Services;
using Microsoft.Extensions.DependencyInjection;

namespace DynaCache.MemoryCache.Extensions
{
public static class ServiceCollectionExtensions
{
public static void AddMemoryCacheService(this IServiceCollection services)
{
services.AddSingleton<IDynaCacheService, MemoryCacheService>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#endregion

using System;
using System.Runtime.Caching;
using System.Threading;
using DynaCache.Services;
using Microsoft.Extensions.Caching.Memory;
using MemCache = System.Runtime.Caching.MemoryCache;

namespace DynaCache.MemoryCache
Expand All @@ -21,7 +25,7 @@ public class MemoryCacheService : IDynaCacheService, IDisposable
/// <summary>
/// The in-memory cache instance for this service.
/// </summary>
private readonly MemCache _cache = new MemCache("CacheService");
private MemCache _cache = new MemCache("CacheService");

/// <summary>
/// Tries to get a cached object from the cache using the given cache key.
Expand Down Expand Up @@ -65,10 +69,25 @@ public virtual void SetCachedObject<T>(string cacheKey, T data, int duration)
}
else
{
_cache.Add(cacheKey, data, DateTime.Now.AddSeconds(duration));
var cacheItemPolicy = new CacheItemPolicy() //TODO to settings
{
SlidingExpiration = TimeSpan.FromSeconds(duration)
};

_cache.Set(cacheKey, data, cacheItemPolicy);
}
}

public void ClearCache()
{
var newCache = new MemCache("CacheService");
var oldCache = _cache;

_cache = newCache;

oldCache.Dispose();
}

/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
Expand Down
17 changes: 17 additions & 0 deletions DynaCache.Core.TestApp/CustomConverters/CacheConverters.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Collections.Generic;

namespace DynaCache.TestApp.CustomConverters
{
public static class CacheConverters
{
public static string TestConvert(Test test)
{
return test.Kekos.ToString();
}

public static string ListConvert<T>(List<T> list)
{
return string.Join(",", list);
}
}
}
17 changes: 17 additions & 0 deletions DynaCache.Core.TestApp/DynaCache.Core.TestApp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>DynaCache.TestApp</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\DynaCache.Core.MemoryCache\DynaCache.Core.MemoryCache.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// All rights reserved.
#endregion

using System.Collections.Generic;

namespace DynaCache.TestApp
{
/// <summary>
Expand All @@ -16,6 +18,6 @@ public interface IRandomService
/// <param name="minInclusive">The minimum value to return (inclusive).</param>
/// <param name="maxExclusive">The maximum value to return (exclusive).</param>
/// <returns>The random number.</returns>
int GetRandomNumber(int minInclusive, int maxExclusive);
int GetRandomNumber(List<int> minInclusive);
}
}
Loading