Class SetController
java.lang.Object
com.loomcache.springboot.controller.SetController
@RestController
@Conditional(LoomServerEnabledCondition.class)
@RequestMapping("/api/set")
public class SetController
extends Object
REST controller for DistributedSet operations.
Endpoints: POST /api/set — add an element to the set GET /api/set/{element} — check if element exists DELETE /api/set/{element} — remove an element GET /api/set — get all elements GET /api/set/size — get set size DELETE /api/set — clear all elements
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd an element to the set.org.springframework.http.ResponseEntity<Void> clear()Clear all elements from the set.Check if an element exists in the set.Get set elements using cursor pagination backed byDistributedSet.scan(long, String, int).Remove an element from the set.size()Get the size of the set.
-
Constructor Details
-
SetController
-
-
Method Details
-
add
@RolesAllowed({"ADMIN","USER"}) @PostMapping public org.springframework.http.ResponseEntity<Map<String,Object>> add(@RequestBody @Nullable String element) Add an element to the set.- Parameters:
element- the element to add (plain string in request body)- Returns:
- response with added flag and current set size
-
contains
-
remove
@RolesAllowed({"ADMIN","USER"}) @DeleteMapping("/members/{element}") public org.springframework.http.ResponseEntity<Map<String,Object>> remove(@PathVariable String element) Remove an element from the set.- Parameters:
element- the element to remove- Returns:
- response with removed flag and current set size
-
getAll
@RolesAllowed({"ADMIN","USER","READONLY"}) @GetMapping public org.springframework.http.ResponseEntity<Map<String, @Nullable Object>> getAll(@RequestParam(defaultValue="100") int limit, @RequestParam(defaultValue="0") String cursor) Get set elements using cursor pagination backed byDistributedSet.scan(long, String, int).Unlike the previous
stream().sorted().toList()implementation, this does not build a full sorted snapshot on each request and does not hit the snapshot hard cap — so the endpoint remains usable for sets larger thanDistributedSet.MAX_SNAPSHOT_ITEMS. Response size is still bounded byMAX_SET_RESPONSE_BYTESand per-pageMAX_SET_RETRIEVAL_SIZE. -
size
-
clear
Clear all elements from the set.- Returns:
- response with success flag
-