I have been using PHP's gettext extension for a while and I am satisfied with its capabilities. I was wondering if there was a point in writing a class that will cache the strings from the .mo
file to a Memcached server, for example.
Can I benefit from caching strings, collected by gettext or should I leave it as it is?
No, you can't benefit from caching your .mo
files to external cache like Memcached. The native gettext extension have its own caching built-in.
Due to the fact that PHP's gettext functions retrieve translation only from a .mo
file, makes it impossible for PHP to get the translations from a Memcached server.
The only option is to cache the strings from your .mo
file as a string array in your Memcached server, but that would make the method of getting translations slower than the native one, so there is no point in making that.
Use the native gettext, it has its own caching algorithms. Loading up your code with external caching classes may result in useless code, which will slow down your site performance, rather than making it faster. Moreover, you will already have lost your time writing the external caching class.