UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'TE347zuiUuhatWtAyn6QCQ8ZGca33J8B2F602AHbmSw='
WHERE
key_id = '33a27c9ff536c28cf51512cd682293f22456faa21c32c331f7ca24bbe927a8ce'
AND (
token = 'TE347zuiUuhatWtAyn6QCQ8ZGca33J8B2F602AHbmSw='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)