MCPcopy Create free account
hub / github.com/dbProjectRED/redimo.go / SRANDMEMBER

Method SRANDMEMBER

sets.go:246–273  ·  view source on GitHub ↗
(key string, count int64)

Source from the content-addressed store, hash-verified

244}
245
246func (c Client) SRANDMEMBER(key string, count int64) (members []string, err error) {
247 if count < 0 {
248 count = -count
249 }
250
251 builder := newExpresionBuilder()
252 builder.addConditionEquality(c.pk, StringValue{key})
253
254 resp, err := c.ddbClient.QueryRequest(&dynamodb.QueryInput{
255 ConsistentRead: aws.Bool(c.consistentReads),
256 ExpressionAttributeNames: builder.expressionAttributeNames(),
257 ExpressionAttributeValues: builder.expressionAttributeValues(),
258 KeyConditionExpression: builder.conditionExpression(),
259 Limit: aws.Int64(count),
260 TableName: aws.String(c.table),
261 }).Send(context.TODO())
262
263 if err != nil {
264 return members, err
265 }
266
267 for _, item := range resp.Items {
268 parsedItem := parseItem(item, c)
269 members = append(members, parsedItem.sk)
270 }
271
272 return
273}
274
275func (c Client) SREM(key string, members ...string) (removedMembers []string, err error) {
276 for _, member := range members {

Callers 2

SPOPMethod · 0.95
TestSetModifiersFunction · 0.80

Calls 7

newExpresionBuilderFunction · 0.85
parseItemFunction · 0.85
addConditionEqualityMethod · 0.80
conditionExpressionMethod · 0.80
StringMethod · 0.45

Tested by 1

TestSetModifiersFunction · 0.64