schema31/php-couchdb-watcher 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

schema31/php-couchdb-watcher

最新稳定版本:0.1.0

Composer 安装命令:

composer require schema31/php-couchdb-watcher

包简介

A simple watcher to attach callbacks to CouchDB documents changes

README 文档

README

This package provides a simple watcher to attach callbacks to CouchDB documents changes.

Installation

The recommended installation method is by using composer

composer require schema31/php-couchdb-watcher

Usage

Three steps are required in order to use the watcher.

Create it passing a key to save last change processed, CouchDB url and options.

<?php

use Schema31\CouchDBWatcher\Watcher;

$options = [
  'since' => 'now',  // taken into account only if store is empty, default is '0'
  'store' => new Schema31\CouchDBWatcher\Store\FileStore() // FileStore is the default one. You can provide your own object, that implements the  StoreInterface
];

$watcher = new Watcher('main_db', 'https://couch.com/db', $options);

Then attach all the callbacks you want.

<?php

$watcher->addCallback(function($change) {
   echo $change->id.PHP_EOL;
});

And just run it.

<?php

$watcher->run();

Error handling

If any of the defined callbacks produces an error program will exit, so you can fix it and then launch again. The last change processed is saved in the store only if all the callbacks are executed without errors.

统计信息

  • 总下载量: 832
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2020-04-28