CacheProvider.cs 685 B

1234567891011121314151617181920212223
  1. using Microsoft.Extensions.DependencyInjection;
  2. using System;
  3. namespace Bowin.Common.Cache
  4. {
  5. public interface ICacheProvider
  6. {
  7. void Config(IServiceCollection service);
  8. object Add(string key, object entry);
  9. object Add(string key, object entry, DateTime utcExpiry);
  10. object Get(string key);
  11. void Remove(string key);
  12. void Set(string key, object entry);
  13. void Set(string key, object entry, DateTime utcExpiry);
  14. }
  15. public static class CacheProvider
  16. {
  17. public static void Config<T>(IServiceCollection service) where T : ICacheProvider, new()
  18. {
  19. new T().Config(service);
  20. }
  21. }
  22. }