dongrong5189 2013-06-11 09:18
浏览 7
已采纳

性能,apc定义语言文件中的常量或apc fetch

Today i have a new very weird question. I am trying to find a way to cache language pot files.

The standard way that CakePHP does this is it parses the file into an array and then returns the key value pair. I am looking at increasing the performance for this due to the file growing exponentially

I have four solutions for this but i don't know which of them will be easily maintainable and supply the fastest performance.

Option 1: Use CakePHP's standard method for translations but just split the files up a little bit and use the __d() function

Option 2: Use a class i wrote to parse the contents of all the langauge files and cache them using apc. Then retrieve the translation via apc_fetch

Option 3: Serialize the translation array using either serialize or json_encode (which ever works the fastest) and defining it using apc_define_contants

Option 4: Use apc_define_contants to define every key in the translation file as a contant with its value

I am stuck on this and i don't know what will be best

  • 写回答

1条回答 默认 最新

  • doucheng9634 2013-06-11 12:24
    关注

    I can point you to some other possible solutions:

    1. Cache them in memcache - nice if you have some (enough) RAM
    2. Cache them in fatcache - a nice one if you have SSDs on your server
    3. Serve them from Redis - Since Redis is a very fast key-value store you should be able to move all your transalations to it, or just parse the .po/.pot files and "cache" them in redis. However with these approaches you will have to see how exactly to handle the cache and where to attach/retrieve it. There are a RedisEngine and MemcacheEngine in CakePHP.

    Maybe your best solution would be some in-memory cache, like memcache.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘