UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'kgGuNQ7fSwsN6HvCEujyTwgoAAi3dfkFrrQ4255a58E='
WHERE
key_id = 'b323bf892c2bd7369f3cfda8ecb5a962417995f32f97b03adbd863bb58ed250a'
AND (
token = 'kgGuNQ7fSwsN6HvCEujyTwgoAAi3dfkFrrQ4255a58E='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)