duanfu1945 2015-07-07 08:37
浏览 35
已采纳

在riak中使用键删除地图

I am using riak php client and have datatype map. I want to delete entire map by key which is itemid. here is my code

        $location = new Location($itemID, $this->itemBucket);
        $map = (new \Command\Builder\FetchMap($this->riak))
        ->atLocation($location)
        ->build()
        ->execute()->getMap();

        (new \Command\Builder\UpdateMap($this->riak))
        ->removeMap($itemID)
        ->atLocation($location)
        ->withContext($map->getContext())
        ->build()
        ->execute();

but this is not working.

  • 写回答

1条回答 默认 最新

  • doutangguali32556 2015-07-07 21:42
    关注

    I think you are confusing the KV key containing a map object and a map key containing a nested map.

    This location will refer to "http://riaknode:8098/buckets/$this->itemBucket/keys/$itemID"

        $location = new Location($itemID, $this->itemBucket);
    

    This retrieves the mapt object contained by the above bucket/key

        $map = (new \Command\Builder\FetchMap($this->riak))
        ->atLocation($location)
        ->build()
        ->execute()->getMap();
    

    This attempts to remove the element with the key $itemID from the returned map object

        (new \Command\Builder\UpdateMap($this->riak))
        ->removeMap($itemID)
        ->atLocation($location)
        ->withContext($map->getContext())
        ->build()
        ->execute();
    

    If you want to remove the entire map stored under that bucket/key, you probably need to use a \Command\Builder\DeleteObject

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分