Memcached没有听到过期时间(Memcached not listening to expiration time)
我正在将Memcached与我在CodeIgniter中编写的PHP Web应用程序结合使用。 我利用这个Memcached库https://github.com/tomschlick/memcached-library当我缓存数据时,我给它一个7200或2小时的到期时间。
模型查询的片段:
$result = $this->memcached_library->get(md5($sql)); if (!$result) { $cursor = $this->db->query($sql); $result = $cursor->row(); $this->memcached_library->set(md5($sql), $result, 7200); } return $result;
很酷,这适用于将数据设置为Memcached。 我可以看到结果,一切都运作良好。 问题出现在将此数据放入Memcached后2小时后。
根据我的理解,当执行get函数时,Memcached应该认识到缓存的数据已经超过其过期日期,因此将其标记为无效(但不一定将其从内存中删除)。 当PHP调用获取数据时,它应返回false,这将导致我的if语句被评估为true并重新获取数据并再次在Memcached中设置数据。
但是,似乎Memcached从未说过数据无效,并且在2小时到期限制之前存在相同的旧数据。 如果我在Memcached上手动调用flush(使缓存中的所有数据无效),数据将再次正确设置为Memcached,但我们再次遇到相同的2小时到期限制问题。
I'm using Memcached in conjunction with my PHP web app written in CodeIgniter. I utilize this Memcached library https://github.com/tomschlick/memcached-library When I cache data, I give it an expiration time of 7200, or 2 hours.
Snippet of a model query:
$result = $this->memcached_library->get(md5($sql)); if (!$result) { $cursor = $this->db->query($sql); $result = $cursor->row(); $this->memcached_library->set(md5($sql), $result, 7200); } return $result;
Cool, this works for setting data into Memcached. I can see the results, all is working well. The problem comes in that after 2 hours after placing this data into Memcached.
From my understanding, when executing the get function, Memcached should recognize that the cached data has hit past its expired date and thus marks it as invalid (not necessarily deleting it from memory however). When the PHP call to get the data, it should return false, which will then in turn cause my if statement to be evaluated as true and refetch the data and set the data in Memcached yet again.
However, it seems as if Memcached never says the data is invalid, and the same old data is in there from before the 2 hour expiration limit. If I manually call flush on Memcached (invalidating all data in the cache), the data is set into Memcached properly yet again, but we run into the same 2 hour expiration limit problem yet again.
原文:https://stackoverflow.com/questions/14225755
最满意答案
一个子报表! 这将是最干净的方式。
- 在收据ID页脚中,插入一个子报表。
- 在子报表中,使用
Receipt_Deduction
表。- 在子报表链接中,根据
Receipt_ID = Receipt_Deduction.Receipt_ID
在子报表中选择记录- 将您的扣减内容移至子报表的详细信息部分。
- 在父报告中,删除
Receipt_Deduction
组,也可能删除详细信息表。- 如果您愿意,甚至可以将您的详细内容移至“详细信息”部分,以便您可以移除
Receipt_Detail
组。A subreport! That would be the cleanest way.
- In the receipt ID footer, insert a subreport.
- In the subreport, use the
Receipt_Deduction
table.- In Subreport Links, select records in the subreport based on
Receipt_ID = Receipt_Deduction.Receipt_ID
- Move your deductions content to the subreport's detail section.
- In the parent report, remove the
Receipt_Deduction
group, and perhaps the detail table too.- If you want, you could even move your detail content to the Detail section, so you can remove the
Receipt_Detail
group.
相关问答
更多-
收入和支出数据库中同一字段的2个不同值? 如果是这样,请创建如下所示的公式以存储收入和费用总值,并将其放在您的组页脚上 if {database your field} = "Income" then numbervar Income := {your group total} else numbervar Expenses := {your group total} 然后在报表页脚上的第二个公式中减去它们(numbervar Income - numbervar Expenses) are income ...
-
一个子报表! 这将是最干净的方式。 在收据ID页脚中,插入一个子报表。 在子报表中,使用Receipt_Deduction表。 在子报表链接中,根据Receipt_ID = Receipt_Deduction.Receipt_ID在子报表中选择记录 将您的扣减内容移至子报表的详细信息部分。 在父报告中,删除Receipt_Deduction组,也可能删除详细信息表。 如果您愿意,甚至可以将您的详细内容移至“详细信息”部分,以便您可以移除Receipt_Detail组。 A subreport! That w ...
-
在创建数据库连接时使用命令并在那里使用相同的查询,现在在设计中将您的字段放在详细信息中。 while creating database connection use command and use the same query exactly there and now in design place your fields in details.
-
我希望我能理解你的问题,但是如果你在Attended上分组那么你应该能够通过计数功能得到你想要的东西。 I was over complicating it, because I'm inexperienced and in a hurry... I made a formula to separate both values: if tonumber({PacientesAtendidosYNoAtendidos.Atendido}) = 0 then 0 else 1 Then, I just gro ...
-
创建一个公式字段,并做同样的事情,在这里你可以在任何地方使用公式字段。 创建一个公式字段: "Company Name:"+ {Group #1} //if Group1 is not string then convert using CSTR Create a formula field and the do the same, here you can use formula field anywhere. Create a formula field: "Company Name:"+ {Grou ...
-
crystal使用表中不同行的记录报告组名称公式(crystal reports group name formula using a record from a different line in table)[2022-10-14]
如果您在commmand表中使用SQL执行此操作,这可能非常简单: select a.Group, a.Section, a.Description, b.GroupName from GroupSection a left outer join ( select concat( format(b.Group, 0), '. ', a.Description) as GroupName, b.Group from GroupSection b ... -
如果第一个cfield值为空,则需要添加一个条件来抑制公式。 你可以通过两种方式做到这一点: 1)在您的剩余时间公式中添加条件。 如果你想在你的细节部分也空白,试试这个。 右键单击 - >抑制 - >在那里添加下一个条件: if(isnull({job.esthours})) 2)在剩余时间总结中添加条件。 如果你想出于某种原因在你的Details部分显示Remeining Values的负值,这会更好。 右键单击 - >抑制 - >在那里添加下一个条件: if(isnull(sum({job.estho ...
-
好的,所以看起来你只需要在Client字段之前在VisualCode组之前创建一个新组。 获得两个组后,您应该能够继续使用新的客户端组插入摘要字段。 我知道此摘要将显示1.5而不是您的格式(1:30:00),但此练习只是为了确保您获取数据,然后您可以在数据正确后使用公式更改格式。 完成后,您应该能够在“报告字段”下的公式编辑器的字段树中找到此新摘要字段。 然后,您可以将格式化函数的每个SUM({LaborTicket.HoursWorked}, {LaborTicket.VisualCode})部分更改为新 ...
-
带来你的结果 在报告>组专家,按药物分组。 然后我在详细信息中删除了Drug 在Group Header 1,Section Report中,检查Underlay Follow Section 删除Bold用于第1组药物治疗 您可以在此处下载Crystal Report Bring in your results Under Report > Group Expert, group by Drug. Then I deleted Drug in Details In Group Header 1, Sect ...
-
您是否尝试过“使用多列格式化组”? 在详细信息部分选择“使用多列格式化”后,这是在“部分专家”的“布局”选项卡中可见的选项。 请参阅此文档 ,查看页面中间的图像,以便在对话框中查看。 Have you tried "Format Groups with multiple columns"? It's an option visible in the Layout tab of the Section Expert after you select "Format with multiple columns" ...