LocalCloud includes Redis configured as a job queue system for processing background tasks, handling asynchronous operations, and managing workloads efficiently.
# Producer: Add job to queueLPUSH jobs:email '{"to":"user@example.com","subject":"Welcome"}'# Consumer: Process job from queueBRPOP jobs:email 0 # Blocking pop
# Add jobs with different prioritiesLPUSH jobs:high '{"type":"urgent_notification"}'LPUSH jobs:medium '{"type":"email"}'LPUSH jobs:low '{"type":"cleanup"}'# Process high priority firstBRPOP jobs:high jobs:medium jobs:low 5
@app.taskdef send_notification(user_id, message, channels=None): channels = channels or ['email', 'push'] user = get_user(user_id) if 'email' in channels: send_email.delay(user.email, "Notification", message) if 'push' in channels: send_push_notification.delay(user.device_token, message) if 'sms' in channels: send_sms.delay(user.phone, message)
@app.taskdef data_ingestion_workflow(source_url): # Download data data = download_data.delay(source_url) # Clean and validate cleaned_data = clean_data.delay(data.get()) # Store in database store_data.delay(cleaned_data.get()) # Generate reports generate_report.delay(cleaned_data.get())