Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3784474
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:22:58+00:00 2026-05-19T11:22:58+00:00

A few days ago I came across this blog post which provides a pluggable

  • 0

A few days ago I came across this blog post which provides a pluggable cache manager to use different cache providers. basically, we have an ICacheProvider Interface:

public interface ICacheProvider
{
  void Store(string key, object data);
  void Destroy(string key);
  T Get<T>(string key);
}

And a CacheManager Class:

public class CacheManager
{
  protected ICacheProvider _repository;
  public CacheManager(ICacheProvider repository)
  {
      _repository = repository;
  }

  public void Store(string key, object data)
  {
      _repository.Store(key, data);
  }

  public void Destroy(string key)
  {
      _repository.Destroy(key);
  }

  public T Get<T>(string key)
  {
      return _repository.Get<T>(key);
  }
}

And finally, we can write our own provider:

public class SessionProvider : ICacheProvider
{
  public void Store(string key, object data)
  {
      HttpContext.Current.Cache.Insert(key, data);
  }

  public void Destroy(string key)
  {
      HttpContext.Current.Cache.Remove(key);
  }

  public T Get<T>(string key)
  {
      T item = default(T);
      if (HttpContext.Current.Cache[key] != null)
      {
          item = (T)HttpContext.Current.Cache[key];
      }
      return item;
  }
}

Well, I’m pretty sure this code uses Adapter Pattern based on the definition at http://www.dofactory.com/Patterns/PatternAdapter.aspx.
But it seems like we can say it uses Repository pattern as well (Except it doesn’t have anything to do with basic CRUD operations on data which is normally where the Repository pattern is used). It wraps up the general stuff for the cache manager in an interface.

Can we say that this code uses Repository pattern and adapter pattern?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T11:22:58+00:00Added an answer on May 19, 2026 at 11:22 am

    I think so, because this isn’t a repository.

    Repository is a collection of domain objects which manages to translate domain business into another thing abstracted from the business itself.

    In other words, I repeat, this isn’t repository.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A few days ago I posted this question and everyone suggested me to use
A few days ago, I watched the video tutorial which explains how to use
I came accross an issue a few days ago which I'd completely forgotten about,
I came across Play! framework a few days ago.It is mentioned that public variable
Since it came out a few days ago, I am sure at least some
A few days ago I asked this question about jquery ajax function invoking action
So the nHibernate 2.1 Alpha came out a few days ago, but the announcement
A few days ago, I posted this question and this question asking about how
A few days ago i asked this question: Displaying images from Facebook photo albums
So basically, few days ago one of my website clients, came to me, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.