UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'gS56mI/UD+f+cBQWOi3g2kSvw3JMHOabDbxtcAXb8+M='
WHERE
key_id = 'd04a278097a0a4f729e445549c294848077af8eaefe158e1b6572e0c5f0b52ea'
AND (
token = 'gS56mI/UD+f+cBQWOi3g2kSvw3JMHOabDbxtcAXb8+M='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)