Skip to content

v0.5.0

Release Date: 2026-06-20

Highlights

New session storage package with multi-site isolation, size controls, and per-user session limits. Redis backend added to KVS subsystem.

Added

Session Storage Package

A new session/ package provides secure, backend-agnostic session storage:

import (
    "github.com/plexusone/omnistorage-core/session"
    sessionmemory "github.com/plexusone/omnistorage-core/session/backend/memory"
)

// Create store with controls
store := sessionmemory.NewWithControls(session.Config{
    SiteID:             "academyos",  // Multi-site isolation
    MaxSessionSize:     1024 * 1024,  // 1MB limit
    MaxSessionsPerUser: 5,            // Max 5 concurrent sessions
    DefaultTTL:         24 * time.Hour,
})
defer store.Close()

// Create and store a session
sess, _ := session.NewSession(userID, 24*time.Hour)
sess.Data["role"] = "admin"
store.Create(ctx, sess)

Features:

  • Multi-site isolation - SiteID prevents cross-site session access
  • Size limits - Configurable maximum session size to prevent bloat
  • Per-user limits - MaxSessionsPerUser with automatic oldest eviction
  • JSON validation - Blocks non-serializable data (functions, channels, gob)
  • Violation callbacks - Hook into metrics/alerting for policy violations
  • Structured errors - Machine-readable error codes for HTTP status mapping

Available backends:

  • session/backend/memory - In-memory (development/testing)
  • session/backend/kvs - Adapts any kvs.ListableStore (Redis, SQLite)

Redis KVS Backend

A new Redis backend for the KVS subsystem:

import kvsredis "github.com/plexusone/omnistorage-core/kvs/backend/redis"

store, err := kvsredis.New(kvsredis.Config{
    URL:       "redis://localhost:6379",
    KeyPrefix: "myapp:",
    PoolSize:  10,
})
defer store.Close()

// Set with TTL
store.Set(ctx, "key", []byte("value"), time.Hour)

// Get
data, err := store.Get(ctx, "key")

// List keys by prefix
keys, err := store.List(ctx, "user:")

Session with Redis Backend

Combine session storage with Redis for production deployments:

import (
    "github.com/plexusone/omnistorage-core/session"
    sessionkvs "github.com/plexusone/omnistorage-core/session/backend/kvs"
    kvsredis "github.com/plexusone/omnistorage-core/kvs/backend/redis"
)

// Create Redis KVS backend
redisStore, _ := kvsredis.New(kvsredis.Config{
    URL: "redis://localhost:6379",
})

// Create session store with controls
cfg := session.Config{
    SiteID:             "academyos",
    MaxSessionSize:     1024 * 1024,
    MaxSessionsPerUser: 5,
    DefaultTTL:         24 * time.Hour,
}
store := sessionkvs.NewWithControls(redisStore, cfg)

Documentation

  • Added KVS package documentation (docs/kvs/index.md)
  • Added Session package documentation:
  • Overview (docs/session/index.md)
  • Backends (docs/session/backends.md)
  • Controls (docs/session/controls.md)
  • Updated MkDocs navigation with Key-Value Storage and Session Storage sections

Dependencies

  • Add github.com/redis/go-redis/v9 v9.20.1 for Redis KVS backend
  • Promote github.com/google/uuid to direct dependency
  • Bump github.com/grokify/mogo from 0.74.5 to 0.74.6
  • Bump golang.org/x/crypto from 0.52.0 to 0.53.0
  • Bump golang.org/x/sys from 0.45.0 to 0.46.0
  • Bump modernc.org/libc from 1.72.3 to 1.73.4

Full Changelog

See CHANGELOG.md for the complete list of changes.