From: Roman Bazalevsky Date: Tue, 27 Sep 2016 16:43:45 +0000 (+0300) Subject: Кеширование сгенерированных фраз в Redis X-Git-Url: https://git.rvb.name/php.git/commitdiff_plain/aea3ac7e69b9aa0c21108105fc4de0a0e6878e31?ds=inline;hp=06edffc2f7f6324b194bebdd527d2fcecdb13364 Кеширование сгенерированных фраз в Redis --- diff --git a/festival-php/voice_class_inc.php b/festival-php/voice_class_inc.php index 5f49c36..b5ef032 100644 --- a/festival-php/voice_class_inc.php +++ b/festival-php/voice_class_inc.php @@ -12,7 +12,15 @@ class voice function text2Wav($string,$lang = "ru") { - print_r($this); + $redis = new Redis(); + $hash =''; + if ($redis->pconnect('127.0.0.1', 6379, 2.5)) { + $hash="voice-".hash("sha256","$lang-$string"); + $result=$redis->get($hash); + if ($result) { + return $result; + } + } if ($this->mode == 'festival') { @@ -48,6 +56,9 @@ class voice } if (!$proc_result) { + if ($hash) { + $redis->set($hash,$data); + } return $data; } else { return '';