Skip to content

Commit

Permalink
Merge branch 'release/2013-11.02'
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlaefer committed Nov 10, 2013
2 parents b00e731 + 92a6577 commit d2488fa
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 43 deletions.
2 changes: 1 addition & 1 deletion app/Config/version.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
Configure::write('Saito.v', '2013-11.01');
Configure::write('Saito.v', '2013-11.02');
23 changes: 23 additions & 0 deletions app/Controller/Component/CacheSupportComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,33 @@ class CacheSupportComponent extends Component {

public function initialize(Controller $Controller) {
$this->_CacheSupport = new CacheSupport();
$this->_addConfigureCachelets();
$this->CacheTree = CacheTree::getInstance();
$this->CacheTree->initialize($Controller);
}

/**
* Adds additional cachelets from Configure `Saito.Cachelets`
*
* E.g. use in `Plugin/<foo>/Config/bootstrap.php`:
*
* <code>
* Configure::write('Saito.Cachelets.M', ['location' => 'M.Lib', 'name' => 'MCacheSupportCachelet']);
* </code>
*/
protected function _addConfigureCachelets() {
$_additionalCachelets = Configure::read('Saito.Cachelets');
if (!$_additionalCachelets) {
return;
}
foreach ($_additionalCachelets as $_c) {
if (!class_exists(($_c['name']))) {
App::uses($_c['name'], $_c['location']);
}
$this->_CacheSupport->add(new $_c['name']);
}
}

public function beforeRender(Controller $Controller) {
$Controller->set('CacheTree', $this->CacheTree);
}
Expand Down
67 changes: 43 additions & 24 deletions app/Lib/CacheSupport.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ class CacheSupport extends Object {

protected $_Caches = [];

protected $_buildInCaches = [
// php caches
'ApcCacheSupportCachelet',
'OpCacheSupportCachelet',
// application caches
'CakeCacheSupportCachelet',
'SaitoCacheSupportCachelet',
'ThreadCacheSupportCachelet'
];

public function __construct() {
$this->addCache(
[
// php caches
'Apc' => 'ApcCacheSupportCachelet',
'OpCache' => 'OpCacheSupportCachelet',
// application caches
'Cake' => 'CakeCacheSupportCachelet',
'Saito' => 'SaitoCacheSupportCachelet',
'Thread' => 'ThreadCacheSupportCachelet'
]
);
foreach ($this->_buildInCaches as $_name) {
$this->add(new $_name);
}
}

/**
Expand All @@ -40,15 +42,12 @@ public function clear($cache = null, $id = null) {
}
}

public function addCache($cache) {
foreach ($cache as $key => $_className) {
$this->_addCachelet($key, new $_className);
public function add(CacheSupportCacheletInterface $cache, $id = null) {
if ($id === null) {
$id = $cache->getId();
}
}

protected function _addCachelet($key, CacheSupportCacheletInterface $cachelet) {
if (!isset($this->_Caches[$key])) {
$this->_Caches[$key] = $cachelet;
if (!isset($this->_Caches[$id])) {
$this->_Caches[$id] = $cache;
}
}

Expand All @@ -58,15 +57,27 @@ interface CacheSupportCacheletInterface {

public function clear($id = null);

public function getId();

}

abstract class CacheSupportCachelet implements CacheSupportCacheletInterface {

public function getId() {
return str_replace('CacheSupportCachelet', '', get_class($this));
}

}

App::uses('CakeEvent', 'Event');
App::uses('CakeEventListener', 'Event');
App::uses('CacheTree', 'Lib/CacheTree');

class ThreadCacheSupportCachelet implements CacheSupportCacheletInterface,
class ThreadCacheSupportCachelet extends CacheSupportCachelet implements
CakeEventListener {

protected $_title = 'Thread';

protected $_CacheTree;

public function __construct() {
Expand Down Expand Up @@ -117,7 +128,9 @@ public function clear($id = null) {

}

class SaitoCacheSupportCachelet implements CacheSupportCacheletInterface {
class SaitoCacheSupportCachelet extends CacheSupportCachelet {

protected $_title = 'Saito';

public function clear($id = null) {
Cache::clear(false, 'default');
Expand All @@ -126,7 +139,9 @@ public function clear($id = null) {

}

class ApcCacheSupportCachelet implements CacheSupportCacheletInterface {
class ApcCacheSupportCachelet extends CacheSupportCachelet {

protected $_title = 'Apc';

public function clear($id = null) {
if (function_exists('apc_store')) {
Expand All @@ -138,7 +153,9 @@ public function clear($id = null) {

}

class OpCacheSupportCachelet implements CacheSupportCacheletInterface {
class OpCacheSupportCachelet extends CacheSupportCachelet {

protected $_title = 'OpCache';

public function clear($id = null) {
if (function_exists('opcache_reset')) {
Expand All @@ -148,7 +165,9 @@ public function clear($id = null) {

}

class CakeCacheSupportCachelet implements CacheSupportCacheletInterface {
class CakeCacheSupportCachelet extends CacheSupportCachelet {

protected $_title = 'Cake';

public function clear($id = null) {
Cache::clearGroup('persistent');
Expand Down
2 changes: 2 additions & 0 deletions app/Plugin/M/Config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
'scopes' => ['mobile-client']
]
);

Configure::write('Saito.Cachelets.M', ['location' => 'M.Lib', 'name' => 'MCacheSupportCachelet']);
3 changes: 3 additions & 0 deletions app/Plugin/M/Controller/MsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public function manifest() {

$this->set(
'touch',
md5(
Configure::read('debug') .
filemtime(App::pluginPath('M') . 'webroot/touch.txt') .
filemtime(App::pluginPath('M') . 'View/Elements/custom_html_header.ctp') .
filemtime(App::pluginPath('M') . 'webroot/dist/js.js') .
filemtime(
Expand All @@ -43,6 +45,7 @@ public function manifest() {
filemtime(
App::pluginPath('M') . 'webroot/dist/theme.css'
)
)
);
}

Expand Down
11 changes: 11 additions & 0 deletions app/Plugin/M/Lib/MCacheSupportCachelet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

App::import('CacheSupport', 'Lib');

class MCacheSupportCachelet extends CacheSupportCachelet {

public function clear($id = null) {
touch(App::pluginPath('M') . 'webroot/touch.txt');
}

}
1 change: 1 addition & 0 deletions app/Plugin/M/webroot/touch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Touch this file to invalidate the cache manifest.
37 changes: 19 additions & 18 deletions docs/dev-namespace.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
Cache
=====

Kind | Namespace | Key | Subkey | Type | Comment
----- | --------- | ---- | ------- | ---- | -------
Cache | Saito | Settings | | | Siehe Configuration
Cache | Saito | Cache | registerGc | timestamp | timestamp of last registerGc
Cache | Saito | Cache | catForAccession | array | cache for categories for accession
Cache | Saito | Cache | appSettings | array | cache for app settings
Cache | Saito | Smilies | smilies_all | array | Smilies from `smilies` table
Configuration | Saito | Cache | Thread | bool | if true use thread cache
Configuration | Saito | useSaltForUserPasswords | | bool | unsalted md5 mode for user passwords
Configuration | Saito | markItUp | nextCssId | int | next CSS-ID for button in the markItUp-CSS
Configuration | Saito | markItUp | additionalButtons | array | Additional buttons shown in the markItUpEditor
Configuration | Saito | Settings | | array | Array with App Settings
Configuration | Saito | Slidetabs | all | array | names of all installed slidetabs
Configuration | Saito | Smilies | smilies_all | array | Smilies from `smilies` table
Configuration | Saito | Smlies | smilies_all_html | array | Html-formatierte Smilies
Configuration | Saito | theme | | string | theme name; default ist "default"
Configuration | Saito | v | | string | internal revision number
Session | User | last_refresh_tmp | | integer | Speichert letzten Session Login für Mark as Read
Kind | Namespace | Key | Subkey | Type | Comment
----- | --------- | ---- | ------- | ---- | -------
Cache | Saito | Settings | | | Siehe Configuration
Cache | Saito | Cache | registerGc | timestamp | timestamp of last registerGc
Cache | Saito | Cache | catForAccession | array | cache for categories for accession
Cache | Saito | Cache | appSettings | array | cache for app settings
Cache | Saito | Smilies | smilies_all | array | Smilies from `smilies` table
Configuration | Saito | Cache | Thread | bool | if true use thread cache
Configuration | Saito | Cachelets | | string |
Configuration | Saito | useSaltForUserPasswords | | bool | unsalted md5 mode for user passwords
Configuration | Saito | markItUp | nextCssId | int | next CSS-ID for button in the markItUp-CSS
Configuration | Saito | markItUp | additionalButtons | array | Additional buttons shown in the markItUpEditor
Configuration | Saito | Settings | | array | Array with App Settings
Configuration | Saito | Slidetabs | all | array | names of all installed slidetabs
Configuration | Saito | Smilies | smilies_all | array | Smilies from `smilies` table
Configuration | Saito | Smlies | smilies_all_html | array | Html-formatierte Smilies
Configuration | Saito | theme | | string | theme name; default ist "default"
Configuration | Saito | v | | string | internal revision number
Session | User | last_refresh_tmp | | integer | Speichert letzten Session Login für Mark as Read


Settings
Expand Down

0 comments on commit d2488fa

Please sign in to comment.