< Back

Set-PSFTaskEngineCache

Sun Jan 19, 2020 6:45 pm

NAME Set-PSFTaskEngineCache



SYNOPSIS

Sets values and configuration for a cache entry.





SYNTAX

Set-PSFTaskEngineCache [-Module] <String> [-Name] <String> [[-Value] <Object>] [[-Lifetime] <TimeSpanParameter>]

[[-Collector] <ScriptBlock>] [[-CollectorArgument] <Object>] [<CommonParameters>]





DESCRIPTION

Allows applying values and settings for a cache.

This allows applying a lifetime to cached data or offering a mechanism to automatically refresh it on retrieval.



This feature is specifically designed to interact with the Task Engine powershell task scheduler (See

Register-PSFTaskEngineTask for details).

However it is open for interaction with all tools.

In particular, the cache is threadsafe to use through these functions.

The cache is global to the process, NOT the current runspace.

Background runspaces access the same data in a safe manner.





PARAMETERS

-Module <String>

The name of the module that generated the task.

Use scriptname in case of using this within a script.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Name <String>

The name of the task for which the cache is.



Required? true

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Value <Object>

The value to set this cache to.



Required? false

Position? 3

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Lifetime <TimeSpanParameter>

How long values stored in this cache should remain valid.



Required? false

Position? 4

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Collector <ScriptBlock>

A scriptblock that is used to refresh the data cached.

Should return values in a save manner, will be called if retrieving data on a cache that has expired.



Required? false

Position? 5

Default value

Accept pipeline input? false

Accept wildcard characters? false



-CollectorArgument <Object>

An argument to pass to the collector script.

Allows passing in values as argument to the collector script.

The arguments are stored persistently and are not subject to expiration.



Required? false

Position? 6

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Set-PSFTaskEngineCache -Module 'mymodule' -Name 'maintenancetask' -Value $results



Stores the content of $results in the cache 'mymodule / maintenancetask'

These values can now be retrieved using Get-PSFTaskEngineCache.









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Set-PSFTaskEngineCache -Module MyModule -Name DomainController -Lifetime 8h -Collector {

Get-ADDomainController }



Registers a cache that lists all domain controllers in the current domain, keeping the data valid for 8 hours

before refreshing it.











RELATED LINKS