sscan
1. 基本語法
sscan(key
, cursor
, ['MATCH', pattern]
, ['COUNT', count]
,callback
)
key
, cursor
, ['MATCH', pattern]
, ['COUNT', count]
,callback
) Parameter
Default
pattern
'*'
count
'10'
內容。
2. 範例
(1) 內容
const arr = ['apple', 'potato', 'onion', 'tomato', 'melon']
client.sadd('food', arr);
let cursor = '0';
client.sscan('food', cursor, (err, scanner) => {
cursor = scanner[0];
let sub_set = scanner[1];
console.log('Cursor: ', cursor);
console.log('Members: ', sub_set);
}
);
Cursor: 0
Members: [ 'tomato', 'apple', 'onion', 'potato', 'melon' ]
(2) 內容
const arr = ['apple', 'potato', 'onion', 'tomato', 'melon']
client.sadd('food', arr);
let cursor = '0';
client.sscan('food', cursor, 'MATCH', '*a*', 'COUNT', '10',
(err, scanner) => {
cursor = scanner[0];
let sub_set = scanner[1];
console.log('Cursor: ', cursor);
console.log('Members: ', sub_set);
}
);
Cursor: 0
Members: [ 'tomato', 'apple', 'potato' ]
Last updated
Was this helpful?