UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '58KsM+c3fwt1dTeRpB5L2AMW1x3712rymAh44H3PYMs='
WHERE
key_id = '9e2374fbce04705d87b8dcacd96a96f491e79a5e7667f0385e0244d9837a5994'
AND (
token = '58KsM+c3fwt1dTeRpB5L2AMW1x3712rymAh44H3PYMs='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)