UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'AB9vKYDNN0EAIu9ysW0v6pTeel8FQE15j8wXbAOClS8='
WHERE
key_id = 'ab29016c692d5191a040a89565427ac74fa6e1d3a10466bc23e943425b9aafba'
AND (
token = 'AB9vKYDNN0EAIu9ysW0v6pTeel8FQE15j8wXbAOClS8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)