spring-session
Spring Session for distributed session management with Redis, JDBC, or Hazelcast. Covers session configuration, security integration, and session events. USE WHEN: user mentions "spring session", "distributed session", "session Redis", "session JDBC", "session cluster", "session management", "@SessionScope" DO NOT USE FOR: stateless JWT auth - use `jwt` skill, OAuth2 tokens - use `oauth2` skill
What this skill does
# Spring Session - Quick Reference
> **Deep Knowledge**: Use `mcp__documentation__fetch_docs` with technology: `spring-session` for comprehensive documentation.
## Dependencies
```xml
<!-- Redis Backend -->
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- JDBC Backend -->
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-jdbc</artifactId>
</dependency>
<!-- Hazelcast Backend -->
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-hazelcast</artifactId>
</dependency>
```
## Architecture
```
┌─────────────────────────────────────────────────────────────┐
│ Load Balancer │
└─────────────────────────────────────────────────────────────┘
│
┌───────────────────┼───────────────────┐
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ Instance 1 │ │ Instance 2 │ │ Instance 3 │
│ App Server │ │ App Server │ │ App Server │
└───────┬───────┘ └───────┬───────┘ └───────┬───────┘
│ │ │
└───────────────────┼───────────────────┘
▼
┌─────────────────────────┐
│ Session Store │
│ (Redis/JDBC/Hazelcast)│
└─────────────────────────┘
```
## Redis Configuration
### application.yml
```yaml
spring:
data:
redis:
host: localhost
port: 6379
password: ${REDIS_PASSWORD:}
session:
store-type: redis
timeout: 30m
redis:
namespace: spring:session
flush-mode: on_save # immediate or on_save
cleanup-cron: "0 * * * * *" # Every minute
```
### Java Configuration
```java
@Configuration
@EnableRedisHttpSession(
maxInactiveIntervalInSeconds = 1800, // 30 minutes
redisNamespace = "myapp:session",
flushMode = FlushMode.ON_SAVE
)
public class SessionConfig {
@Bean
public LettuceConnectionFactory connectionFactory() {
return new LettuceConnectionFactory();
}
@Bean
public RedisSerializer<Object> springSessionDefaultRedisSerializer() {
return new GenericJackson2JsonRedisSerializer();
}
}
```
## JDBC Configuration
### application.yml
```yaml
spring:
session:
store-type: jdbc
timeout: 30m
jdbc:
initialize-schema: always # always, embedded, never
table-name: SPRING_SESSION
cleanup-cron: "0 * * * * *"
```
### Schema
```sql
-- Auto-created with initialize-schema: always
-- Or create manually:
CREATE TABLE SPRING_SESSION (
PRIMARY_ID CHAR(36) NOT NULL,
SESSION_ID CHAR(36) NOT NULL,
CREATION_TIME BIGINT NOT NULL,
LAST_ACCESS_TIME BIGINT NOT NULL,
MAX_INACTIVE_INTERVAL INT NOT NULL,
EXPIRY_TIME BIGINT NOT NULL,
PRINCIPAL_NAME VARCHAR(100),
CONSTRAINT SPRING_SESSION_PK PRIMARY KEY (PRIMARY_ID)
);
CREATE UNIQUE INDEX SPRING_SESSION_IX1 ON SPRING_SESSION (SESSION_ID);
CREATE INDEX SPRING_SESSION_IX2 ON SPRING_SESSION (EXPIRY_TIME);
CREATE INDEX SPRING_SESSION_IX3 ON SPRING_SESSION (PRINCIPAL_NAME);
CREATE TABLE SPRING_SESSION_ATTRIBUTES (
SESSION_PRIMARY_ID CHAR(36) NOT NULL,
ATTRIBUTE_NAME VARCHAR(200) NOT NULL,
ATTRIBUTE_BYTES BYTEA NOT NULL,
CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_PRIMARY_ID, ATTRIBUTE_NAME),
CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_PRIMARY_ID)
REFERENCES SPRING_SESSION(PRIMARY_ID) ON DELETE CASCADE
);
```
## Session Usage
### Controller
```java
@RestController
@RequestMapping("/api")
public class SessionController {
@GetMapping("/session/info")
public Map<String, Object> getSessionInfo(HttpSession session) {
return Map.of(
"sessionId", session.getId(),
"creationTime", new Date(session.getCreationTime()),
"lastAccessedTime", new Date(session.getLastAccessedTime()),
"maxInactiveInterval", session.getMaxInactiveInterval()
);
}
@PostMapping("/session/attribute")
public void setAttribute(
HttpSession session,
@RequestParam String key,
@RequestParam String value) {
session.setAttribute(key, value);
}
@GetMapping("/session/attribute/{key}")
public String getAttribute(HttpSession session, @PathVariable String key) {
return (String) session.getAttribute(key);
}
@DeleteMapping("/session/invalidate")
public void invalidateSession(HttpSession session) {
session.invalidate();
}
}
```
### @SessionAttributes
```java
@Controller
@SessionAttributes("cart")
public class CartController {
@ModelAttribute("cart")
public Cart createCart() {
return new Cart();
}
@PostMapping("/cart/add")
public String addToCart(
@ModelAttribute("cart") Cart cart,
@RequestParam Long productId) {
cart.addItem(productId);
return "redirect:/cart";
}
@PostMapping("/cart/checkout")
public String checkout(
@ModelAttribute("cart") Cart cart,
SessionStatus status) {
orderService.createOrder(cart);
status.setComplete(); // Remove from session
return "redirect:/orders";
}
}
```
### @SessionScope Bean
```java
@Component
@SessionScope
public class UserPreferences implements Serializable {
private String theme = "light";
private String language = "en";
private int pageSize = 20;
// getters and setters
}
@RestController
public class PreferencesController {
@Autowired
private UserPreferences preferences; // Session-scoped
@PutMapping("/preferences/theme")
public void setTheme(@RequestParam String theme) {
preferences.setTheme(theme);
}
}
```
## Security Integration
```java
@Configuration
@EnableWebSecurity
public class SecurityConfig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.sessionManagement(session -> session
.sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED)
.maximumSessions(1) // One session per user
.maxSessionsPreventsLogin(true) // Prevent new login
.sessionRegistry(sessionRegistry())
)
.logout(logout -> logout
.invalidateHttpSession(true)
.deleteCookies("SESSION")
);
return http.build();
}
@Bean
public SpringSessionBackedSessionRegistry<?> sessionRegistry() {
return new SpringSessionBackedSessionRegistry<>(sessionRepository);
}
}
```
### Find Sessions by Principal
```java
@Service
@RequiredArgsConstructor
public class SessionManagementService {
private final FindByIndexNameSessionRepository<?> sessionRepository;
public Map<String, ?> findSessionsByUsername(String username) {
return sessionRepository.findByPrincipalName(username);
}
public void invalidateUserSessions(String username) {
Map<String, ?> sessions = sessionRepository.findByPrincipalName(username);
sessions.keySet().forEach(sessionRepository::deleteById);
}
}
```
## Custom Session Repository
```java
@Configuration
@EnableRedisHttpSession
public class CustomSessionConfig {
@Bean
public SessionRepositoryCustomizer<RedisIndexedSessionRepository> customizer() {
return sessionRepository -> {
sessionRepository.setDefaultMaxInactiveInterval(Duration.ofMinutes(30));
sessionRepository.setRedisKeyNamespace("app:sessions");
};
}
}
```
## Session Events
```java
@Component
@Slf4j
public class SessRelated in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.