NAME
Concierge::Sessions::File - File backend for session storage
VERSION
version 0.8.5
SYNOPSIS
# Used internally by Concierge::Sessions
my $sessions = Concierge::Sessions->new(
backend => 'file',
storage_dir => '/tmp/sessions',
);
DESCRIPTION
Concierge::Sessions::File provides file-based storage for session data. Each session is stored as a separate JSON file named after the session ID. This backend is useful for testing, development, and debugging.
This backend inherits from Concierge::Sessions::Base and implements all required backend methods. Users typically do not interact with this class directly - they use Concierge::Sessions which manages the backend.
FEATURES
Human-readable JSON format for easy debugging
Simple file system operations
No database dependencies
Suitable for testing and development
Lower performance than SQLite (~1,000 ops/sec vs 4,000-5,000)
STORAGE
Each session is stored as a separate JSON file in the storage_dir:
/path/to/storage_dir/
├── 3a7f2b9c01e84d5f6a0b1c2d3e4f5a6b7c8d9e0f
├── 9b8c7d6e5f4a3b2c1d0e9f8a7b6c5d4e3f2a1b0c
└── ...
File names are the session_id (no extension).
File contents:
{
"session_id": "3a7f2b9c01e84d5f6a0b1c2d3e4f5a6b7c8d9e0f",
"user_id": "user123",
"created_at": 1737526800.12345,
"expires_at": 1737530400.12345,
"last_updated": 1737526800.12345,
"session_timeout": 3600,
"status": { "state": "active", "dirty": 0 },
"data": { "cart": [], "preferences": {} }
}
PERFORMANCE
The File backend provides moderate performance suitable for testing:
Create session: ~0.001 seconds
Get session: ~0.001 seconds
Update session: ~0.001 seconds
Delete session: ~0.001 seconds
Performance depends on file system speed and can vary significantly between systems. For production use, consider the SQLite backend.
USAGE
This backend is ideal for:
Development and testing
Debugging (view session data directly in text editor)
Environments without database support
Learning and experimentation
For production deployments, use the SQLite backend for better performance and reliability.
SEE ALSO
Concierge::Sessions - Session manager
Concierge::Sessions::Base - Backend base class
Concierge::Sessions::SQLite - SQLite backend implementation
JSON::PP - JSON encoding/decoding
File::Spec - File path operations
AUTHOR
Bruce Van Allen <bva@cruzio.com>
LICENSE
Artistic License 2.0
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 363:
Non-ASCII character seen before =encoding in '├──'. Assuming UTF-8