Changeset 657
- Timestamp:
- 08/05/2011 02:22:08 AM (10 months ago)
- Location:
- trunk/WordPress/plugin/transposh
- Files:
-
- 3 edited
-
core/constants.php (modified) (1 diff)
-
wp/transposh_admin.php (modified) (1 diff)
-
wp/transposh_db.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WordPress/plugin/transposh/core/constants.php
r645 r657 21 21 define('TP_ENABLE_CACHE', TRUE); 22 22 //What is the cache items TTL 23 define('TP_CACHE_TTL', 3600); 23 define('TP_CACHE_TTL', 3600*24); 24 //Constants for memcached 25 define('TP_MEMCACHED_SRV', '127.0.0.1'); 26 define('TP_MEMCACHED_PORT', 11211); 24 27 25 28 //Class marking a section not be translated. -
trunk/WordPress/plugin/transposh/wp/transposh_admin.php
r653 r657 232 232 } 233 233 234 if (! function_exists('apc_fetch') && !function_exists('xcache_get') && !function_exists('eaccelerator_get')) {234 if (!(class_exists('Memcache') && @$this->memcache->connect(TP_MEMCACHED_SRV, TP_MEMCACHED_PORT)) && !function_exists('apc_fetch') && !function_exists('xcache_get') && !function_exists('eaccelerator_get')) { 235 235 $this->add_warning('tp_cache_warning', __('We were not able to find a supported in-memory caching engine, installing one can improve performance.', TRANSPOSH_TEXT_DOMAIN) . ' <a href="http://transposh.org/faq#performance">' . __('Check Transposh FAQs', TRANSPOSH_TEXT_DOMAIN) . '</a>'); 236 236 } -
trunk/WordPress/plugin/transposh/wp/transposh_db.php
r604 r657 40 40 /** @var string translation log table name */ 41 41 private $translation_log_table; 42 /** @var boolean is memcached working */ 43 private $memcache_working = false; 44 /** @var Memcache the memcached connection object */ 45 private $memcache; 42 46 43 47 /** … … 48 52 $this->translation_table = $GLOBALS['wpdb']->prefix . TRANSLATIONS_TABLE; 49 53 $this->translation_log_table = $GLOBALS['wpdb']->prefix . TRANSLATIONS_LOG; 54 55 if (class_exists('Memcache')) { 56 logger('I am using memcached!', 3); 57 $this->memcache_working = true; 58 $this->memcache = new Memcache; 59 @$this->memcache->connect(TP_MEMCACHED_SRV, TP_MEMCACHED_PORT) or $this->memcache_working = false; 60 logger($this->memcache_working); 61 } 50 62 } 51 63 … … 60 72 $cached = false; 61 73 $key = $lang . '_' . $original; 62 if (function_exists('apc_fetch')) { 74 if ($this->memcache_working) { 75 $cached = $this->memcache->get($key); 76 logger('memcached', 5); 77 } elseif (function_exists('apc_fetch')) { 63 78 $cached = apc_fetch($key, $rc); 64 79 if ($rc === false) return false; … … 94 109 if ($translated !== null) $translated = implode('_', $translated); 95 110 $rc = false; 96 if (function_exists('apc_store')) { 111 if ($this->memcache_working) { 112 $rc = $this->memcache->set($key, $translated); //, time() + $ttl); 113 } elseif (function_exists('apc_store')) { 97 114 $rc = apc_store($key, $translated, $ttl); 98 115 } elseif (function_exists('xcache_set')) { … … 118 135 if (!TP_ENABLE_CACHE) return; 119 136 $key = $lang . '_' . $original; 120 if (function_exists('apc_delete')) { 137 if ($this->memcache_working) { 138 $this->memcache->delete($key); 139 } elseif (function_exists('apc_delete')) { 121 140 apc_delete($key); 122 141 } elseif (function_exists('xcache_unset')) { … … 132 151 function cache_clean() { 133 152 if (!TP_ENABLE_CACHE) return; 134 if (function_exists('apc_clear_cache')) { 153 if ($this->memcache_working) { 154 $this->memcache->flush(); 155 } elseif (function_exists('apc_clear_cache')) { 135 156 apc_clear_cache('user'); 136 157 } elseif (function_exists('xcache_unset_by_prefix')) {
Note: See TracChangeset
for help on using the changeset viewer.
