UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'Bw5n7WB24BI7LYDJ0L2zJZ93tvx8Xt5Dh6a9K64Owd0='
WHERE
key_id = '4767a976c928c9f1e1c1691360b73107d5a1618001e34bdbe307a444342447f6'
AND (
token = 'Bw5n7WB24BI7LYDJ0L2zJZ93tvx8Xt5Dh6a9K64Owd0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)