Windows 索引服务如何工作?
我的任务是通过这样的行为来实现服务。 我的问题是:
索引服务如何记住哪些文件已被索引,哪些文件没有,哪些文件已更改并需要重新索引它们?
另外,我可以停止该服务,然后在几天后启动它,它会继续工作。 它有自己的数据库,其中包含有关文件的信息吗?
谢谢
I have a task to implement service with behavior like this one.
My question is:
How Indexing Service remember what files was already indexed and what no, what files changed and need to reindex them?
Also, I can stop this service and then start it after a few days, it continues to work.
Does it have its own database with information about files?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,索引服务会在调用
FindFirstChangeNotification
创建的句柄上使用WaitForSingleObject / WaitForMultipleObjects
留在后台。如果您想支持可以关闭索引服务(或用于已存在的目录),您绝对应该存储每个文件上上次运行索引的时间戳。您可以将此与 LastWriteTime 进行比较给定文件的。编辑:您应该使用 ReadDirectoryChangesW 和另一个线程异步索引文件以确保不会错过任何更改。您可以为每个要索引的文件生成新线程(昂贵),也可以使用作业队列和固定数量的工作线程(最好是 1 或 2 个)
Usually the indexing-service stays in the background using
WaitForSingleObject / WaitForMultipleObjects
on Handles created by calls toFindFirstChangeNotification
. If you want to support that the indexing service can be shut down (or be used for an already existent directory) you should definitely store the timestamp of your last index run on every file. You can compare this to the LastWriteTime of the given file.EDIT: you should use ReadDirectoryChangesW and another thread which asynchronously indexes the files to be sure to not miss any changes. You can either spawn new threads for every file to index(expensive) or use a job queue and a fixed amount of worker threads(1 or 2 preferably)