如何解决Aerospike :: Exceptions :: Aerospike:Ruby Client不支持的服务器功能?

时间:2018-09-12 12:09:23

标签: ruby aerospike

当我尝试使用ruby客户端写入Aerospike时,出现以下异常:-

Aerospike :: Exceptions :: Aerospike:不支持的服务器功能

详细信息:-

Aerospike version:- 4.3
Client: [Ruby] aerospike - 2.4.0
namespaces: NS1, NS2, NS3 

注意:NS2和NS3的单bin索引数据为true

代码(导致异常):-

client = Aerospike::Client.new('aerospike:3000')
key = Aerospike::Key.new('NS2', 'set name', 'this is the key')
data = { 'record'  => 1 }
client.put(key, data) # this line raises the exception
Aerospike::Exceptions::Aerospike: Unsupported Server Feature

如果我将NS2的密钥更改为NS1,则不会引发异常。

1 个答案:

答案 0 :(得分:4)

您收到的“不受支持的服务器功能”错误是因为Ruby客户端默认情况下会将用户密钥发送到服务器,但是Aerospike服务器不支持存储内存数据和单项存储的用户密钥。垃圾箱设置。您应该在服务器日志中看到这样的错误消息:

Sep 13 2018 02:42:20 GMT: WARNING (rw): (rw_utils.c:153) {sbin} can't store key if data-in-memory & single-bin

您需要通过将send_key的写入策略设置设置为false来禁止将密钥作为放置请求的一部分发送:

$ bundle exec irb
2.5.0 :001 > require 'aerospike'; include Aerospike;
 => Object
2.5.0 :002 > client = Client.new; key = Key.new('sbin', 'test', 'foo'); nil
 => nil
2.5.0 :003 > client.put(key, Bin.new('', 42), send_key: false)
 => nil
2.5.0 :004 > client.get(key).bins['']
 => 42
相关问题