dtol41388 2009-04-30 06:07
浏览 29

如何记忆这些数据?

SELECT a.* b.* c.*
FROM TOPIC a, BOARD b, MSGS c
WHERE c.MessageID = 1 AND a.TopicID = c.MessageID AND b.BoardID = c.BoardID

How to memcache this data?

set_cache("MY_WACKY_QUERY_1", data) note: 1 is the message id

Now there are lots of places in the code which update these 3 tables (independantly of each other), so we need to del_cache("XXX_1"); whenever any of these updates and inserts affect MSGS, TOPIC, or BOARD data for, or relating to, the message with id 1

Is there an easy solution?

  • 写回答

1条回答 默认 最新

  • duanmeng3573 2009-04-30 07:44
    关注

    You can't delete data from memcached without knowing the exact cache key that was used to store it. There is no "index" or "key list" from which you can search for stored data.

    One solution might be to make your cache lifetimes short enough so that stale data is mostly a non-concern.

    Or maybe... I think I'm confused. To me, it kinda looks like you can do this.

    <?php
    
    $memcache = new Memcache;
    $memcache->connect( 'memcache_host', 11211 );
    
    // do select query here, store into $result
    
    $memcache->set( 'MY_QUERY_1', $result, false, 600 );
    
    // do another select query here, store into $result
    
    $memcache->set( 'MY_QUERY_2', $result, false, 600 );
    
    // Query here updates record with id of 1
    
    $memcache->delete( 'MY_QUERY_1' );
    
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?