Getting Started
What is PowerShell Universal?
Installation
Windows
IIS
Persistent Docker Image
Configuration
Port and HTTPS Certificate
SQL Persistence
Platform
Environments
Variables
Published Folders
Git
Repository
Modules
Secret Management
APIs
Basics
Security
Event Hubs
Automation
Scripts
Scheduling
Triggers
Apps
Basics
Dynamic Regions
Session and Cache
Forms
Navigation
Basic Tables
Designer
Theming
Pages
Forms
Desktop
About
File Associations
Security
Forms
Azure Active Directory and OpenID Connect
Roles
App Tokens
Development
Debugger
Visual Studio Code Extension
PowerShell Module and Management API
Session and Cache
Learn about special scopes in apps
Download this Lecture DocsIn this lecture, we look the session and cache scope for dashboards. Session scope is per-user storage for variables. If the user session expires or the dashboard is restarted, the session date will be reset. This is useful for adjusting dashboards based on user interaction.
The cache scope is used for storing variables across all users of a dashboard. This is useful for storing global data that many users can view but not necessarily change.
Be aware that session and cache scopes are not cleared automatically so storing large amounts of data will increase memory usage.
Example Code used in this lecture
New-UDDashboard -Title 'PowerShell Universal' -Content {
New-UDTypography 'Dashboard 1'
New-UDButton -Text 'Session' -OnClick {
$Session:MySessionVariable = Get-Random
}
New-UDButton -Text 'Cache' -OnClick {
$Cache:MyCacheVariable = Get-Random
}
New-UDAlert -Text "Session: $Session:MySessionVariable"
New-UDAlert -Text "Cache: $Cache:MyCacheVariable"
}