UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'KQYqZdcTyW+PHs7GQ1P3GX7vy0Jt1npRXk5wQQ0yB6w='
WHERE
key_id = 'b0a90dcf4c08b5187ac69ca65f84fad6639831d7482d02aca58f1ab41f3a04fa'
AND (
token = 'KQYqZdcTyW+PHs7GQ1P3GX7vy0Jt1npRXk5wQQ0yB6w='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)