UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'gbsyPBPe+xxTwbfHicorPEhfHgmCOFKkmxKvBdXOtCs='
WHERE
key_id = 'd859f1b78910dc1c3e4e514e839f782c3786e68579d85de2802321fbad598bbc'
AND (
token = 'gbsyPBPe+xxTwbfHicorPEhfHgmCOFKkmxKvBdXOtCs='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)