How to persist objects between requests in PHP

后端 未结 3 1208
南笙
南笙 2020-12-15 20:53

I\'ve been using rails, merb, django and asp.net mvc applications in the past. What they have common (that is relevant to the question) is that they have code that sets up t

3条回答
  •  误落风尘
    2020-12-15 21:27

    Not sure if APC is the only solution but APC does take care of all your issues.

    First, your script will be compiled once with APC and the bytecode is stored in memory.

    If you have something taking long time to setup, you can also cache it in APC as user data. For example, I do this all the time,

                $table = @apc_fetch(TABLE_KEY);
    
                if (!$table) {
                        $table = new Table(); // Take long time
                        apc_store(TABLE_KEY, $table);
                }
    

    With APC, the task of creating table is only performed once per server instance.

提交回复
热议问题