UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'gfa4DjFsFOwulLBINLQnQTMPMdbElDCTO+m8HxbQgFI='
WHERE
key_id = '40ed1061f969133643939834679e9f4dea6d551e7080d6f96c92f9081ea018f0'
AND (
token = 'gfa4DjFsFOwulLBINLQnQTMPMdbElDCTO+m8HxbQgFI='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)