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 Details

  • 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

      @RolesAllowed({"ADMIN","USER","READONLY"}) @GetMapping("/members/{element}") public org.springframework.http.ResponseEntity<Map<String,Object>> contains(@PathVariable String element)
      Check if an element exists in the set.
      Parameters:
      element - the element to check
      Returns:
      response with exists flag
    • 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 by DistributedSet.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 than DistributedSet.MAX_SNAPSHOT_ITEMS. Response size is still bounded by MAX_SET_RESPONSE_BYTES and per-page MAX_SET_RETRIEVAL_SIZE.

    • size

      @RolesAllowed({"ADMIN","USER","READONLY"}) @GetMapping("/size") public org.springframework.http.ResponseEntity<Map<String,Object>> size()
      Get the size of the set.
      Returns:
      response with set size
    • clear

      @RolesAllowed("ADMIN") @DeleteMapping public org.springframework.http.ResponseEntity<Void> clear()
      Clear all elements from the set.
      Returns:
      response with success flag