diff --git a/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testComing.st b/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testComing.st index 4f40294..d217b64 100644 --- a/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testComing.st +++ b/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testComing.st @@ -26,6 +26,6 @@ testComing self assert: nextThree first content equals: '2' -> '2'. self assert: nextThree second content equals: '3' -> '3'. self assert: nextThree third content equals: '4' -> '4'. - self assert: strm length > 6. + self assert: strm length >= 5. strm trimTo: 0. self assert: strm length equals: 0 \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testDelete.st b/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testDelete.st new file mode 100644 index 0000000..125ad3b --- /dev/null +++ b/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testDelete.st @@ -0,0 +1,31 @@ +tests +testDelete + | strm one two three msgId conts deletedCount | + strm := self newStreamNamed: 'testDelete'. + strm trimTo: 0. + self assert: strm length equals: 0. + one := 'one' -> '1'. + two := 'two' -> '2'. + three := 'three' -> '3'. + strm nextPut: one. + msgId := strm nextPut: two. + strm nextPut: three. + + conts := strm contents. + self assert: conts size equals: 3. + conts := strm first: 2. + self assert: conts size equals: 2. + self assert: conts first content equals: one. + self assert: conts second content equals: two. + + deletedCount := strm deleteAt: msgId. + self assert: deletedCount equals: 1. + conts := strm contents. + self assert: conts size equals: 2. + conts := strm first: 2. + self assert: conts size equals: 2. + self assert: conts first content equals: one. + self assert: conts second content equals: three. + + strm trimTo: 0. + self assert: strm length equals: 0 \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testDeletes.st b/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testDeletes.st new file mode 100644 index 0000000..ba0a1dd --- /dev/null +++ b/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testDeletes.st @@ -0,0 +1,29 @@ +tests +testDeletes + | strm one two three msgIds conts deletedCount | + strm := self newStreamNamed: 'testDeletes'. + strm trimTo: 0. + self assert: strm length equals: 0. + one := 'one' -> '1'. + two := 'two' -> '2'. + three := 'three' -> '3'. + strm nextPut: one. + msgIds := { two. three } collect: [:each | strm nextPut: each]. + + conts := strm contents. + self assert: conts size equals: 3. + conts := strm first: 2. + self assert: conts size equals: 2. + self assert: conts first content equals: one. + self assert: conts second content equals: two. + + deletedCount := strm deleteAtIds: msgIds. + self assert: deletedCount equals: 2. + conts := strm contents. + self assert: conts size equals: 1. + conts := strm first: 2. + self assert: conts size equals: 1. + self assert: conts first content equals: one. + + strm trimTo: 0. + self assert: strm length equals: 0 \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStream.class/instance/deleteAtIds..st b/repository/RediStick-Stream-Objects.package/RsStream.class/instance/deleteAtIds..st new file mode 100644 index 0000000..648edb3 --- /dev/null +++ b/repository/RediStick-Stream-Objects.package/RsStream.class/instance/deleteAtIds..st @@ -0,0 +1,3 @@ +deleting +deleteAtIds: streamMessageIds + ^ self endpoint xDel: self name ids: streamMessageIds \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStream.class/instance/nextPutAll..st b/repository/RediStick-Stream-Objects.package/RsStream.class/instance/nextPutAll..st index 2d66b87..113f073 100644 --- a/repository/RediStick-Stream-Objects.package/RsStream.class/instance/nextPutAll..st +++ b/repository/RediStick-Stream-Objects.package/RsStream.class/instance/nextPutAll..st @@ -1,3 +1,3 @@ adding nextPutAll: keyValuesOrAssociations - ^ keyValuesOrAssociations do: [ :each | self nextPut: each ] \ No newline at end of file + ^ keyValuesOrAssociations collect: [ :each | self nextPut: each ] \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStream.class/instance/nextPutAssociations.at.trimUsing..st b/repository/RediStick-Stream-Objects.package/RsStream.class/instance/nextPutAssociations.at.trimUsing..st index 4467fe5..646745c 100644 --- a/repository/RediStick-Stream-Objects.package/RsStream.class/instance/nextPutAssociations.at.trimUsing..st +++ b/repository/RediStick-Stream-Objects.package/RsStream.class/instance/nextPutAssociations.at.trimUsing..st @@ -1,8 +1,8 @@ adding nextPutAssociations: keyValueAssocs at: streamMessageId trimUsing: optionsBlock - ^ self endpoint - xAdd: self name - createNotExists: self autoCreate - trimUsing: optionsBlock - id: streamMessageId - fieldsAndValues: keyValueAssocs \ No newline at end of file + ^ RsStreamMessageId fromStringOrNil: (self endpoint + xAdd: self name + createNotExists: self autoCreate + trimUsing: optionsBlock + id: streamMessageId + fieldsAndValues: keyValueAssocs) \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStreamMessageId.class/class/fromStringOrNil..st b/repository/RediStick-Stream-Objects.package/RsStreamMessageId.class/class/fromStringOrNil..st new file mode 100644 index 0000000..c252a23 --- /dev/null +++ b/repository/RediStick-Stream-Objects.package/RsStreamMessageId.class/class/fromStringOrNil..st @@ -0,0 +1,4 @@ +instance creation +fromStringOrNil: aStringOrNil + aStringOrNil ifNil: [ ^nil ]. + ^ self fromString: aStringOrNil \ No newline at end of file diff --git a/repository/RediStick-Stream.package/RsRedisEndpoint.extension/instance/xDel.id..st b/repository/RediStick-Stream.package/RsRedisEndpoint.extension/instance/xDel.id..st index 633a320..cc123d8 100644 --- a/repository/RediStick-Stream.package/RsRedisEndpoint.extension/instance/xDel.id..st +++ b/repository/RediStick-Stream.package/RsRedisEndpoint.extension/instance/xDel.id..st @@ -4,4 +4,4 @@ xDel: key id: id ^ self unifiedCommand: { 'XDEL'. key. - id } \ No newline at end of file + id asString } \ No newline at end of file diff --git a/repository/RediStick-Stream.package/RsRedisEndpoint.extension/instance/xDel.ids..st b/repository/RediStick-Stream.package/RsRedisEndpoint.extension/instance/xDel.ids..st index 151a10d..3589acc 100644 --- a/repository/RediStick-Stream.package/RsRedisEndpoint.extension/instance/xDel.ids..st +++ b/repository/RediStick-Stream.package/RsRedisEndpoint.extension/instance/xDel.ids..st @@ -1,7 +1,8 @@ *RediStick-Stream xDel: key ids: ids - - ^ self unifiedCommand: { - 'XDEL'. - key. - }, ids asArray \ No newline at end of file + | args | + args := { + 'XDEL'. + key } asOrderedCollection. + args addAll: (ids collect: [ :each | each asString ]). + ^ self unifiedCommand: args \ No newline at end of file