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
Learn how to use different storage backends for various use cases. Perfect for getting started with True Storage’s core functionality.
Explore session management capabilities with practical examples showing how to handle user sessions effectively.
Advanced Usage
Master environment variable management and configuration with real-world scenarios and best practices.
Learn how to work with different database storage options and integrate with various persistence layers.
Code Snippets
Basic Storage Operations
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
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
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
Explore the Module Reference for detailed API documentation
Check out the Troubleshooting Guide guide for common issues
Join our community for support and discussions