- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在开发一个应用程序,我主要使用 View 来获取数据。
我尝试做的是存储文档,重定向并检查存储的文档是否可用(这是通过 View 完成的,因为我不是在寻找文档键而是在寻找不同的值)。
我在用什么?
Debian Wheezy 上的 PHP(5.4.21)、Couchbase(2.1.1) 和用于 Couchbase(1.1) 的 PHP SDK。
那么发生了什么?
我使用 API 函数 set($id, $document)
存储文档,然后使用 API 函数 view($designDocument, $viewName, $ 触发 View 更新options)
,其中 $options
至少包含 'stale'=>false
,然后重定向到另一个页面,我在其中检查新添加的文档/或者只是想显示它。
但是新添加的文档并不总是显示或者不总是通过我的存在检查。
下面是我使用的更详细的代码:
public function store(AbstractDocument $document)
{
$result = $this->bucket->storeDocument($document->getId(),
json_encode($document));
$this->afterSave();
return $result;
}
public function storeDocument($id, $document)
{
if (!is_string($document)) {
$document = json_encode($document);
}
$res = $this->couchbase->set($id, $document);
return $res;
}
public function afterSave()
{
$this->bucket->triggerViewIndexing(
$this->getDesignDocumentName(),
Config::KEY_COUCHBASE_VIEW_USER_USERLIST
);
}
public function triggerViewIndexing($designDocument, $viewName)
{
$options = ['limit' => 1, 'stale' => false];
$res = $this->couchbase->view($designDocument, $viewName, $options);
}
如代码所示,我将 stale 参数设置为 false,以确保更新索引。
但它似乎不起作用。
在写这个问题之前,我查看了 Couchbase 论坛中的一些主题、Stackoverflow 上的帖子、适用于 Couchbase 的 PHP SDK 的文档以及 Couchbase 的一般文档。
所以我想我明白如何stale应该工作什么limitations好像有。
如果我假设 stale 有效,但仅当文档不再在内存中但正在写入磁盘(或已经写入)时,这是错误的,请随时纠正我。
由于我尝试做的事情不起作用,我尝试了不同的方法,在一些解释和文档中也提到了这些方法应该有助于实现我想要的结果。
例如,我想如果stale
的默认行为是update_after
,那么触发索引更新两次,就可以解决问题。
好吧,它没有。
其他值得注意的事情是
$this->couchbase->keyDurability($id,$res);
$this->couchbase->observe($id, $res);
我在使用 set
存储文档后直接使用了它们,单独使用它们,出于绝望而组合使用。也没有成功。
我假设这里的错误是,PHP SDK 要么没有通过 stale=false
参数和 keyDurability没有做它应该做的事。当我在检查新创建的文档时也传递 stale=false
时,当然两者(触发和检查)都在同一个存储桶和 View 上工作。
或者我在没有注意到的情况下做了一些可怕的错误。
如果有人能为我指出正确的方向并希望解释问题出在哪里,我会很高兴,因为我无法理解正在发生的事情。根据我的理解,一切都应该至少与 keyDurability
和 stale
一起工作。
最佳答案
关于更新 View 的“问题”是,它只使用持久保存到磁盘的数据。您可以使用 keyDurability() 来检查是否发生了这种情况,但是您需要您刚刚编写的元素的 id 和 cas。
我会将您的 triggerViewIndexing 函数更改为如下所示。
/**
* @param $designDocument
* @param $viewName
* @param null $id
* @param null $cas
*/
public function triggerViewIndexing($designDocument, $viewName, $id = null, $cas = null)
{
if (!empty($id) && !empty($cas)) {
$details = [
'persist_to' => 1, //The number of nodes the document should be persisted to
'timeout' => 2000, // The max time to wait for durability
'interval' => 100 //The interval between checking the state of the document
];
$this->couchbase->keyDurability($id, $cas, $details);
}
$options = ['limit' => 1, 'stale' => false];
$res = $this->couchbase->view($designDocument, $viewName, $options);
}
如果项目被写入磁盘,这将每 100 毫秒检查一次,最多 2000 毫秒。之后,触发 View 会刷新数据。
关于php - 从 PHP SDK 设置后 Couchbase View 未更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20103737/
我正在细读 http://www.khronos.org/网站,只找到了 OpenCL 的头文件(不是我不关心的 OpenGL)。如何获取 OpenCL SDK? 最佳答案 AMD 的 ATI Str
Android 项目中最低(最低 sdk)和最高(目标 sdk)级别是否有任何影响。这些东西是否会影响项目的可靠性和效率。 最佳答案 没有影响,如果您以 SDK 级别 8 为目标,那么您的应用将以 9
“min sdk version/target sdk version”和“compile sdk version”有什么区别?我知道 min 和 target sdk 是什么意思,但是 compil
我正在尝试运行 Dji Mobile-Sdk-Android:https://github.com/dji-sdk/Mobile-SDK-Android使用 dji 网站上的说明:https://de
我目前正在向我的 iPhone 应用程序添加新的 Facebook iOS sdk 3.1.1。我看到 sdk 有重大变化。例如。我的旧 sdk 创建一个 Facebook 对象并从 FBReques
我最近刚刚下载了 Xcode 4.6 with mac 10.8.4 with iOS 6.0 SDK package,我立即注意到我无法使用我的 iPhone 3Gs with iOS 4.6 进行
我尝试下载 OpenCL SDK。但是没办法。我有一个 AMD GPU,所以我在谷歌上搜索了 AMD SDK,但是来自谷歌的所有链接和一些教程都被破坏了,不可能通过 AMD 开发者网站找到 sdk。
安装 Google Cloud SDK 后,当我运行时 gcloud 授权登录 我收到一条错误消息: Your browser has been opened to visit: https://a
我一直在 nvidia 网站上搜索 GPU 计算 SDK,因为我正在尝试构建具有 cuda 支持的点云库 (PCL)。但是,在 nvidia 网站上,我只能找到工具包的链接,而不是 SDK 的单个下载
Closed. This question needs to be more focused。它当前不接受答案。 想改善这个问题吗?更新问题,使其仅关注editing this post一个问题。 2
当我打开 Android SDK 管理器时,会出现一个屏幕“选择要安装的包”。它列出了一堆带有绿色复选标记(已经安装)的软件包,还有一些带有 x's 的软件包,它们没有安装。如果我选择“全部接受”,它
在开发过程中,我发布了 SDK 21 Lollipop,但我无法在我的 KitKat 设备上使用它。应用程序非常简单,我只将 SDK 用于动画和 Material 设计,但是当我尝试对 Play 商店
enter image description here friend 们好 在使用 Linux、jenkins 和 docker 探索 dotnet 核心时,我遇到了构建问题,该问题在标题“/usr
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
我创建了一个flutter项目,运行flutter packages get,输出如下:【二】flutter包搞定等待另一个 flutter 命令释放启动锁...第二次运行“flutter packa
这个问题在这里已经有了答案: What are the Android SDK build-tools, platform-tools and tools? And which version sh
我使用 Corona SDK 已经快一年了,并且开发了几个简单的游戏。我现在正在寻找的是在 Corona SDK 中创建 3D 幻觉的某种方法。如果有人有 Corona 3D 方面的经验,我将不胜感激
我有一个CLDC 1.1 / MIDP 2.0项目,可以使用Java ME SDK 3.2很好地进行编译。 最近,我已将Java SE升级到8,结果Java ME SDK开始在Windows启动时显示
有没有办法以编程方式控制连接到华擎主板的 RGB 照明?我知道华硕有一个 Aura SDK,但华擎是否也有一个用于他们的硬件? 如果是,我在哪里可以找到它? 最佳答案 没有用于华擎多彩的 sdk。但是
如何使用 crm 2011 sdk 和 XrmServiceContext 创建事务? 在下一个示例中,'new_brand' 是一些自定义实体。我想创建三个品牌。第三个拥有错误的 OwnerID g
我是一名优秀的程序员,十分优秀!