| 1 |
/** |
| 2 |
* Docket Cache. |
| 3 |
* |
| 4 |
* @author Nawawi Jamili |
| 5 |
* @license MIT |
| 6 |
* |
| 7 |
* @see https://github.com/nawawi/docket-cache |
| 8 |
*/ |
| 9 |
function docket_cache_worker( name, config ) { |
| 10 |
if ( config.debug ) { |
| 11 |
console.log( config.slug + ':worker: ping ' + name ); |
| 12 |
} |
| 13 |
jQuery.post( |
| 14 |
config.ajaxurl, { |
| 15 |
"action": "docket_worker", |
| 16 |
"token": config.token, |
| 17 |
"type": name |
| 18 |
}, |
| 19 |
function( response ) { |
| 20 |
if ( config.debug ) { |
| 21 |
console.log( response.data + ' -> ' + response.success ); |
| 22 |
} |
| 23 |
|
| 24 |
if ( response.cachestats ) { |
| 25 |
if ( config.debug ) { |
| 26 |
console.log( response.cachestats ); |
| 27 |
} |
| 28 |
setTimeout( |
| 29 |
function() { |
| 30 |
var $selector = jQuery( document ) |
| 31 |
.find( 'div#docket-cache' ); |
| 32 |
|
| 33 |
if ( response.cachestats.obc ) { |
| 34 |
$selector.find( 'td#objectcache-stats0' ) |
| 35 |
.html( response.cachestats.obc ); |
| 36 |
} |
| 37 |
|
| 38 |
if ( response.cachestats.opc ) { |
| 39 |
$selector.find( 'td#opcache-stats0' ) |
| 40 |
.html( response.cachestats.opc ); |
| 41 |
} |
| 42 |
|
| 43 |
if ( response.cachestats.obcs ) { |
| 44 |
$selector.find( 'td#objectcache-stats' ) |
| 45 |
.html( response.cachestats.obcs ); |
| 46 |
} |
| 47 |
|
| 48 |
if ( response.cachestats.opcs ) { |
| 49 |
$selector.find( 'td#opcache-stats' ) |
| 50 |
.html( response.cachestats.opcs ); |
| 51 |
} |
| 52 |
|
| 53 |
if ( response.cachestats.opcdc ) { |
| 54 |
$selector.find( 'td#dcopcache-stats' ) |
| 55 |
.html( response.cachestats.opcdc ); |
| 56 |
} |
| 57 |
|
| 58 |
if ( response.cachestats.opcwp ) { |
| 59 |
$selector.find( 'td#wpopcache-stats' ) |
| 60 |
.html( response.cachestats.opcwp ); |
| 61 |
} |
| 62 |
|
| 63 |
if ( response.cachestats.ofile ) { |
| 64 |
$selector.find( 'td#file-stats' ) |
| 65 |
.html( response.cachestats.ofile ); |
| 66 |
} |
| 67 |
|
| 68 |
if ( response.cachestats.odisk ) { |
| 69 |
$selector.find( 'td#disk-stats' ) |
| 70 |
.html( response.cachestats.odisk ); |
| 71 |
} |
| 72 |
}, |
| 73 |
3000 |
| 74 |
); |
| 75 |
} |
| 76 |
} |
| 77 |
); |
| 78 |
}; |