dongqie2010 2016-10-20 13:54
浏览 49

APCu TTL无法运行php 7.0

By specifying the TTL, the item should be aged out of the cache. But it is not working. This is very very simple. the TTL is set to 1 second. Have I made a mistake?

My version;

PHP 7.0.12-1+deb.sury.org~xenial+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.12-1+deb.sury.org~xenial+1, Copyright (c) 1999-2016, by Zend Technologies

My script;

cat apcu.php
<?php

$key="KEY";

function xxx($key) {
  if (apcu_exists($key)) {
    print ("In Store
");
    $value = apcu_fetch($key);
    var_dump($value);
  } else {
    $value = "Hello Big Daddy";
    apcu_add($key, $value, 1);
    print ("Not in store, adding
");
  }
}

xxx($key);
sleep(2);
xxx($key);
sleep(3);
xxx($key);

Output;

php apcu.php
Not in store, adding
In Store
string(15) "Hello Big Daddy"
In Store
string(15) "Hello Big Daddy"

I do not think the item should be in the Cache on the second call.

But even if someone said it should, then it should certainly not be in the Cache on the third call.

  • 写回答

1条回答 默认 最新

  • douqian1835 2017-08-01 22:41
    关注

    When apc.use_request_time is set to true, which is the default, this is what happens -- the SAPI request start time is used for TTL calculations, not the time each function is called.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化