doutong7216 2010-09-26 05:13
浏览 37
已采纳

PHP MySQL和队列,表锁定,读/写器问题

I have following Scenario:

PHP(Server, Writer) ----> MySQL Database <------ PHP(Client, Reader/ Writer);
  • PHPS = PHP Server
  • PHPC = PHP Client

How it works?

  1. PHPS writes data to temporary database tables (queue_*).
  2. PHPC is triggered by a 1 hour cron.
  3. PHPC starts, connects to database and caches all records locally (how? no idea, local mysql db? sqlite?)
  4. PHPC executes tasks defined in those records one by one
    • if the task is successful it removes it from databases
    • if its unsuccessful it adds that record in database under a reports table.

How do i implement this such that

  • No half written records from PHPS get to PHPC.
  • PHPC can cache all records locally after one query to process them.

Any other ideas that you might have and share are highly appreciated.

  • 写回答

2条回答 默认 最新

  • douji5397 2010-09-26 05:19
    关注

    MySQL's default locking will ensure that no "half-written" rows are fetched. As far as "caching locally", it seems like all that means in your scenario is reading them out of the database into a local PHP data structure like an array.

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

报告相同问题?