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

  • Home
  • SEARCH
  • 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 8378485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:56:25+00:00 2026-06-09T15:56:25+00:00

I want to use AOP to apply cache functionality to all of method of

  • 0

I want to use AOP to apply cache functionality to all of method of BLL layer in my website.
Just like below:

[Cacheable(new string[] { "id" }, GroupName = "UserInfoByID", LiveTime = "00:05:00")]
public UserInfo GetUserInfoByID(int id)
{
    return UserDAO.GetUserInfo(id);
}

The first argument of Cacheable attribute figures out which arg of method will be used to create cache key. The second argument GroupName figures out the prefix of cache key. As the above example, a key-“UserInfoByID(123)” will be generated (supposing the query id be 123). I create another attribute:

[PurgeCache(new string[] { "userInfo.ID" }, GroupName = "UserInfoByID")]
public void UpdateUserInfo(UserInfo userInfo)
{
    UserDAO.UpdateUserInfo(userInfo);
}

It will use userInfo.ID and the same GroupName-UserInfoByID to generate a same key to purge cache: UserInfoByID(123). Is it every simple to use and elegant? There is, however ,a very tough problem. I have another method:

public void ManageUser(int[] userID, int status)
{
    UserDAO.ManageUser(userID, status);
}

The method is used to change user’s status. How can I refresh cache after execution? Should I generate key with int[] userID one by one and purge all of them? Is it too complex in consideration of high performance cache, even though it’s just a very simple case. Supposing I have a list query mehod:

[Cacheable(new string[] { "regionID" }, GroupName = "UserList", LiveTime = "00:05:00")]
public List<UserInfo> GetUserList(int regionID)
{
    List<UserInfo> result = UserDAO.GetUserList(regionID);
    return result;
}

If I change user’s status to disactiviated, how can I refresh the cache of above method?

  • 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-06-09T15:56:26+00:00Added an answer on June 9, 2026 at 3:56 pm

    I built a small aop caching fw sometime ago, MbCache, where I decided to let invalidation be an “explicit” operation rather than a configuration issue. Made things a lot easier.

    Even though this fw uses code configuration rather than attributes (I don’t really like the attribute thingy for different reasons – personal opinion), the same could be applicable here I guess. You should maybe remove your PurgeCacheAttribute and instead let that be some runtime operation/method?

    This is how invalidation is made in MbCache, maybe that will give you some ideas?

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

Sidebar

Related Questions

I want use ajax.net to do some js. like below: ScriptManager.RegisterStartupScript(Submit, typeof(Button), alert, location.href='test.aspx';,
I want use A-Z buttons on a html page like shown below (only sample
I want use a single php file to handle all of my voting requests.
i want use some data from a website with web service. i have a
I'm just starting out with postsharp/AOP. I want to make some instrumentation for C#
Assuming I want to use a dependency injection framework in an AOP approach, with
I want use page that has this form: <form method=post action=modules.php?name=search> <input onkeypress=FKeyPress(this); onkeydown=FKeyDown(this);
I want my read methods not to use a transaction since this is just
I want to use an AOP framework, but I have two constraints. Any framework
I want to use @cacheable annotations on objects that are not managed by spring.

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.