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 8056011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:34:50+00:00 2026-06-05T08:34:50+00:00

I have set up a configuration system that will grab the configuration from a

  • 0

I have set up a configuration system that will grab the configuration from a MySQL database. And I have got it working, but now I realize that to get the Value from the Cache, I have to use this long messy code.

CacheLayer.Instance.Caches["app_config"].Current.EmailALertInterval

I would like to remove Current, but I haven’t managed to figure out if it’s possible to have the class do this directly. At the moment the implementation looks like this.

public T Current
{
    get
    {
        if (_current == null)
        {
            ReloadConfiguration();
        }

        return _current;
    }
}

But I would like to simply it to this:

CacheLayer.Instance.Caches["app_config"].EmailALertInterval

I am looking at something like this, but this only works with indexers.

public T this[T key]

EDIT: Just to add some more context I will add some more code.

This is CacheLayer. It essentially allows me to store multiple configurations. I may have one that is for example the general app config, but I can also grab an array of Emails used.

public Dictionary<String,IGenericCache<dynamic>> Caches
{
    get
    {
        return _caches;
    }
}

public void AddCache(String config)
{
    _caches.Add(config,new GenericCache<dynamic>(config));
}

Inside my GenericCache I load the configuration using a JSON string stored in a MySQL db.

_current = JsonConvert.DeserializeObject<T>(db.dbFetchConfig(config));

The reason that GenericConfig is T and not dynamic is because I want to be able to make a custom implmentation outside of the CacheLayer, one that does not necessarily use dynamic.

ANother example on how I want this to be used.

List<String> EmailList = CacheLayer.Instance.Caches["EmailList"].Current;

This would in fact grab an JSON Array from the MySQL containing a list of Emails.

Any ideas?

  • 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-05T08:34:51+00:00Added an answer on June 5, 2026 at 8:34 am

    Add a new property

    public int EmailALertInterval
    {
        get { return Current.EmailALertInterval; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HI, I want to have set configuration settings for a unit test project that
I have written a Linux system wide C++ program /usr/bin/PROG_X that uses a configuration
I am working on a Log4Net configuration that will log all unhandled exceptions. I
Does Java have a default System Environment Variable that will always be read/appended when
I'm writing a game that will have a lot of information (configuration, some content,
I have set up 2 servers which are linked. From my LOCAL SERVER, I
I've been tasked with porting/refactoring a Web Application Platform that we have from ASP.NET
I have code that manipulates binary files using fstream with the binary flag set
I am working on a MVC 3 application that will be hosted in a
I have spring Java config object that loads my properties but does not override

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.