Skip to content

Commit

Permalink
Added Cache::instance() to get active instance
Browse files Browse the repository at this point in the history
  • Loading branch information
lux committed Nov 6, 2023
1 parent c69de56 commit 98f58ee
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class Cache {
*/
public $dir = 'cache/datastore';

/**
* Cache object.
*/
private static $_instance;

/**
* Constructor method creates the directory if it's missing.
*/
Expand All @@ -51,6 +56,8 @@ public function __construct ($dir = 'cache/datastore') {
mkdir ($this->dir);
chmod ($this->dir, 0777);
}

self::$_instance = $this;
}

/**
Expand Down Expand Up @@ -102,6 +109,13 @@ public static function init ($conf) {
return new Cache ($dir);
}

/**
* Get the cache instance.
*/
public static function instance () {
return self::$_instance;
}

/**
* Create a timeout file to store the timeout of the cached data.
* Uses a similarly named dot-file to the main file that contains
Expand Down

0 comments on commit 98f58ee

Please sign in to comment.