UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '0sOsV0aHgtTtLkZyVfUvu2iV3k1eWObceSQTKyo8Dkw='
WHERE
key_id = 'cd58e4145de711f929acd3c67903e502f466e8b691de73d34349327245675ea6'
AND (
token = '0sOsV0aHgtTtLkZyVfUvu2iV3k1eWObceSQTKyo8Dkw='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)