Examples and Tutorials

Welcome to True Storage’s examples and tutorials section! Here you’ll find comprehensive guides and practical examples to help you make the most of True Storage’s features.

Quick Start Examples

🔥 Storage Examples

Learn how to use different storage backends for various use cases. Perfect for getting started with True Storage’s core functionality.

Storage Examples
🔄 Session Examples

Explore session management capabilities with practical examples showing how to handle user sessions effectively.

Session Examples

Advanced Usage

🌍 Environment Examples

Master environment variable management and configuration with real-world scenarios and best practices.

Environment Examples
📚 Database Examples

Learn how to work with different database storage options and integrate with various persistence layers.

Database Examples

Code Snippets

Basic Storage Operations

Simple key-value storage
from true_storage import HotStorage

# Initialize storage
storage = HotStorage()

# Store and retrieve data
storage.set("user_id", 12345)
value = storage.get("user_id")  # Returns: 12345

Session Management

Basic session handling
from true_storage import Session

# Create a new session
session = Session()
session.start()

# Use the session
with session.active():
    session.set("cart", ["item1", "item2"])

Environment Variables

Environment configuration
from true_storage import Environment
from true_storage.env import MODES

# Initialize environment
env = Environment()

# Access environment variables
env.set("DEBUG", True, mode=MODES.DEVELOPMENT)
debug_mode = env.get("DEBUG")  # Returns: True

Best Practices

  • Always use context managers for session operations

  • Implement proper error handling

  • Choose appropriate storage backend for your use case

  • Configure compression for large datasets

  • Monitor performance metrics

  • Follow security guidelines

Next Steps