drtkyykai004574380 2010-10-26 00:39
浏览 24
已采纳

memcaching php资源对象

Say I have this code in PHP :

$query = mysql_query("SELECT ...");

the statement returns a resource object. Normally it would get passed to mysql_fetch_array() or one of the mysql_fetch_* functions to populate the data set.

I'm wondering if the resouce object - the $query variable in this case can be cached in memcache and then a while later can be fetched and used just like the moment it's created.

// cache it
$memcache->set('query', $query);

// restore it later
$query = $memcache->get('query');

// reuse it
while(mysql_fetch_array($query)) { ... }

I have googled the question, didn't got much luck.

I'm asking this is because it looks way much light-weighted than the manner of "populate the result array first then cache".

So is it possible?

  • 写回答

2条回答 默认 最新

  • dragon201401 2010-10-26 00:44
    关注

    I doubt it. From the serialize manual entry

    serialize() handles all types, except the resource-type.

    Edit: Resources are generally tied to the service that created them. I don't know if memcached uses serialize however I'd guess it would be subject to the same limitations.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)