首页  

aerospike udf 使用之 record     所属分类 aerospike 浏览量 1442
https://www.aerospike.com/docs/udf/api/record.html

For use-cases that have single-bin configuration set to true, 
the bin name is required to be an empty string for reading or writing the bin for versions 3.15 and above. 
Versions prior to 3.15 do not support UDFs on single-bin namespaces.

single-bin  模式 ,  3.15及以上版本 , 读写时 ,bin name 为空字符串

A Record is provided by the UDF system and can represent an existing record or an empty record. 
It provides access to a record's bins and metadata.

记录 
访问列及元数据

A Record can be accessed much like a Map or Lua Table, where the key can be a String:

rec['a'] = 1
local value = rec['a']

A Record must only contain values of the following types:

integer
string
bytes
list
map

Placing other Lua types - for example, functions or tables - will result in run-time errors.

存放其他类型,报错


record.bin_names()
Get the bin names of a record.
function record.bin_names(r: Record): Lua table

names = record.bin_names(rec)
for i, name in ipairs(names) do
     info("bin %d name = %s", i, tostring(name))
end

bin 1 name = bin1
bin 2 name = bin2
bin 3 name = third bin

record.digest()
Get the digest of a record. The digest is the hash of the key and other values using for distributing the record across the cluster.
function record.digest(r: Record): Bytes

record.gen()
Get the generation value of a record. The generation values is equivalent to a revision number.
function record.gen(r: Record): Integer


record.key()
Get the key of a record.

function record.key(r: Record): string

Returns
The key of the record. Returns nil if the record's key is not stored.

如果key 没有被存储则返回 nil ,默认不存储key

record.last_update_time()
Get the last update time of a record. Since Server version 3.8.3
function record.last_update_time(r: Record): integer


The last update time of the record, expressed in milliseconds since the Citrusleaf epoch (00:00:00 UTC on 1 Jan 2010).
记录的最后一次更新时间,以毫秒为单位表示,从 Citrusleaf 时代开始(2010年1月1日00:00:00 UTC)。

Citrusleaf 是 aerospike 原来的名字


record.numbins()
Get the number of bins in a record.
function record.numbins(r: Record): integer

The number of bins in the record. Returns 1 if the record belongs to a single-bin namespace.

single-bin  模式返回 1


record.setname()
Get the set name of a record.

record.ttl()
Get the time-to-live (ttl) of a record
function record.ttl(r: Record): Integer

The ttl of the record, in seconds.

TTL 秒


record.set_ttl()
Set the time-to-live (ttl) of a record. When the record is updated this ttl will take effect.
function record.set_ttl(r: Record, ttl: Integer): nil

设置TTL

record.drop_key()
Discard a record's key. When the record is updated its key will no longer be stored.
function record.drop_key(r: Record): nil

上一篇     下一篇
go语言历程

go语言特性及优点

lua local function 与 function 区别

aerospike udf 使用之 list

aerospike udf 使用之 map

权益类与固收类基金