WP_Background_Process::generate_key()protectedWC 1.0

Generate key

Generates a unique key based on microtime. Queue items are given a unique key so that they can be merged upon save.

Method of the class: WP_Background_Process{}

No Hooks.

Return

String.

Usage

// protected - for code of main (parent) or child class
$result = $this->generate_key( $length );
$length(int)
Length.
Default: 64

WP_Background_Process::generate_key() code WC 9.4.2

protected function generate_key( $length = 64 ) {
	$unique  = md5( microtime() . rand() );
	$prepend = $this->identifier . '_batch_';

	return substr( $prepend . $unique, 0, $length );
}