UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'TB4hHF4E0zQxb6FNs0sWNiymdWtqN8xwUseYtBMMtn8='
WHERE
key_id = '54866f31ea802b9c491a765a244c9a651fffe03616cf4a22c9a045782bad8cc3'
AND (
token = 'TB4hHF4E0zQxb6FNs0sWNiymdWtqN8xwUseYtBMMtn8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)