UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'aG71f06IqDyfL+rQm2MfQWv2WrJ5p52Ijv+iObXprp0='
WHERE
key_id = '49aed217bd65e5d3362e8cbf6390776e0b19a1d68ee3f64835ed66e2d8ed2147'
AND (
token = 'aG71f06IqDyfL+rQm2MfQWv2WrJ5p52Ijv+iObXprp0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)