Class MapController

java.lang.Object
com.loomcache.springboot.controller.MapController

@RestController @Conditional(LoomServerEnabledCondition.class) @RequestMapping("/api/map") public class MapController extends Object
REST controller for DistributedMap operations.

Endpoints: GET /api/map/{key} — get a value PUT /api/map/{key} — put a value (body = value string) DELETE /api/map/{key} — delete a key GET /api/map — get all keys GET /api/map/size — get map size DELETE /api/map — clear all entries

  • Constructor Details

    • MapController

      public MapController(DistributedMap<String,String> defaultMap, WriteThroughCacheStore cacheStore)
      Create a MapController with a DistributedMap and write-through store.
      Parameters:
      defaultMap - the distributed map to use (must not be null)
      cacheStore - the write-through cache store (must not be null)
      Throws:
      NullPointerException - if any argument is null
  • Method Details

    • get

      @RolesAllowed({"ADMIN","USER","READONLY"}) @GetMapping("/{key}") public org.springframework.http.ResponseEntity<Map<String,Object>> get(@PathVariable String key)
      Get a value from the map by key.
      Parameters:
      key - the key to look up (must not be null)
      Returns:
      response with key and value if found, or 404 Not Found if not present
    • put

      @RolesAllowed({"ADMIN","USER"}) @PutMapping("/{key}") public org.springframework.http.ResponseEntity<Map<String,Object>> put(@PathVariable String key, @RequestBody @Nullable String value)
      Put (insert or update) a value in the map.
      Parameters:
      key - the key to store at (must not be null)
      value - the value to store (plain string in request body, must not be null)
      Returns:
      response with response-safe key, value, previous value, and operation type (insert/update)
    • delete

      @RolesAllowed({"ADMIN","USER"}) @DeleteMapping("/{key}") public org.springframework.http.ResponseEntity<Map<String,Object>> delete(@PathVariable String key)
      Delete a key from the map.
      Parameters:
      key - the key to delete (must not be null)
      Returns:
      response with key and removed value, or 404 Not Found if key not present
    • keys

      @RolesAllowed({"ADMIN","USER","READONLY"}) @GetMapping public org.springframework.http.ResponseEntity<Map<String,Object>> keys(@RequestParam(defaultValue="0") long cursor, @RequestParam(defaultValue="100") int limit)
      Get keys in the map using cursor-based scan (memory-safe pagination).
      Parameters:
      cursor - pagination cursor (0 = start from beginning)
      limit - maximum number of keys to return per page (1-10000, default 100)
      Returns:
      response with keys, count, and nextCursor (0 = scan complete)
    • size

      @RolesAllowed({"ADMIN","USER","READONLY"}) @GetMapping("/size") public org.springframework.http.ResponseEntity<Map<String,Integer>> size()
      Get the current size (number of entries) in the map.
      Returns:
      response with the size value
    • clear

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