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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:17:11+00:00 2026-05-31T04:17:11+00:00

I am trying to build a simple abstract Cache class that can enforce methods

  • 0

I am trying to build a simple abstract Cache class that can enforce methods in subclasses and I am trying to set up default settings for the subclasses to inherit. Here is my basic run down:

    define('APP_ROOT', getcwd());        
    abstract class BaseCache {

            protected $baseCacheDir = APP_ROOT . '/cache';

            abstract function exists($resource);
            abstract function store($resource);
            abstract function delete($resource);
            abstract function check($resource);
        }

    class TemplateCache extends BaseCache {

            protected $CacheDir = $this->baseCacheDir . '/tpl/';
            public function exists($resource) {}...
         }

class LinkCache extends BaseCache {

            protected $CacheDir = $this->baseCacheDir . '/link/';
        }

Is this the proper/best practices way to do this? Is this how you access properties in abstract classes while in a subclass? The $baseCacheDir property shouldn’t be changed and I want to hard-code it in as a default, then have subclasses build off of the base directory. (e.g ‘cache/link’, ‘cache/tpl’, ‘cache/apc’, ‘cache/memcache’)

Thanks.

  • 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-31T04:17:13+00:00Added an answer on May 31, 2026 at 4:17 am
    abstract class BaseCache {
    
        private $baseCacheDir = APP_ROOT . '/cache';
    
        protected final  function getBaseCacheDir() 
        {
            return $this->baseCacheDir;
        }
    
        //And Anoter Thing
        protected final  function getBaseCacheDirConcat($tplDir)
        { 
            return $this->getBaseCacheDir().$tplDir
        } 
    
        abstract function exists($resource);
        abstract function store($resource);
        abstract function delete($resource);
        abstract function check($resource);
    }
    
    class LinkCache extends BaseCache {
    
        protected $CacheDir;
    
        public function __construct() 
        {
            $this->CacheDir = $this->getBaseCacheDirConcat('/link/');
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build a simple jquery plugin that can take selectors as parameters.
I'm trying to build a simple User Template system so that my users can
I'm trying to build a simple Magento Module that needs to connect to the
I am trying to build a simple worker function that takes a config of
Im trying to build a simple AJAX script that uses a form to send
Im trying to build a simple faye realtime based notification system so I can
I am trying to build a simple phonebook in cakephp 2.0 that stores &
I'm trying to build a simple utility for kids where they can play games
I am trying to build a simple div based popup which can be used
I'm trying to build a simple GAE application that would read a textbox, pass

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.