View Issue Details

IDProjectCategoryView StatusLast Update
0000242WackoWikicachepublic2009-08-19 09:38
Reporteradministrator Assigned Toadministrator  
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Target Version4.3.rcFixed in Version4.3.rc 
Summary0000242: implement cache in NpjTranslit
DescriptionSimple per-request cache to speed up this lame but often called function.
Check if there already was such a transliteration request and return its result. Otherwise transliterate as usual and store the result in this cache.
Steps To Reproducehttp://svn.wackowiki.org/viewvc/wackofork?view=rev&revision=59
back port to
http://svn.wackowiki.org/viewvc/wackowiki/trunk/wacko/classes/wacko.php?view=log
Additional Informationmany thanks to banshee1
TagsNo tags attached.
Attached Files
wacko.php.patch (952 bytes)   
Index: wacko.php
===================================================================
--- wacko.php	(revision 190)
+++ wacko.php	(working copy)
@@ -362,6 +362,13 @@
 
    function NpjTranslit($tag, $strtolow = TRAN_LOWERCASE, $donotload=TRAN_LOAD)
    {
+      # Lookup transliteration result in the cache and return it if found
+      static $npj_cache;
+      $cach_key = $tag.$strtolow.$donotload;
+      if (isset($npj_cache[$cach_key])) {
+         return $npj_cache[$cach_key];
+      }
+     
       $_lang = null;
       if (!$this->GetConfigValue("multilanguage")) $donotload = 1;
       if (!$donotload)
@@ -394,7 +401,11 @@
 
       if ($_lang)
       $this->SetLanguage($_lang);
-      return rtrim($tag, "/");
+      $result =  rtrim($tag, "/");
+
+      # Put transliteration result in the cache
+      $npj_cache[$cach_key] = $result;
+      return $result;
    }
 
    function Translit($tag, $direction=1) { //deprecated

wacko.php.patch (952 bytes)   

Activities

administrator

2008-10-27 11:16

administrator   ~0000533

SVNed with revision 191

Issue History

Date Modified Username Field Change
2008-10-27 08:30 administrator New Issue
2008-10-27 08:30 administrator Legacy => NEW
2008-10-27 08:31 administrator File Added: wacko.php.patch
2008-10-27 08:37 administrator Assigned To => administrator
2008-10-27 08:37 administrator Status new => assigned
2008-10-27 08:41 administrator Additional Information Updated
2008-10-27 11:16 administrator Note Added: 0000533
2008-10-27 11:16 administrator Status assigned => resolved
2008-10-27 11:16 administrator Resolution open => fixed
2008-10-27 11:16 administrator Fixed in Version => 5.0.0
2008-10-27 11:16 administrator Target Version => 5.0.0
2009-08-19 09:25 administrator Fixed in Version 5.0.0 => 4.3.rc
2009-08-19 09:38 administrator Target Version 5.0.0 => 4.3.rc
2010-03-08 10:11 administrator Category Cache => cache